bug in stk 3.0b2?

From: Raymond Toy <toy_at_rtp.ericsson.se>
Date: Tue, 13 Feb 1996 11:08:34 -0500

While playing around with scheme, I came across what appears to be a
bug, but it might be due to my misunderstanding of scheme. You be the
judge....

Consider this bit of code:

        (define bug
          (lambda ()
            (let ((n 1000000000)
                  (root 32768))
              (do ((delta (quotient (- root (quotient n root)) 2)
                          (quotient (- root (quotient n root)) 2)))
                  ((<= (abs delta) 1) root)
                (format #t "root = ~s delta = ~s~%" root delta)
                (set! root (- root delta))))))


When I run it in STK 3.0b2 built for Solaris 2.4 (and linux as well),
the output is something like

STk> (load "bug.scm")
STk> (bug)
root = 32768 delta = 1125
root = 31643 delta = -120195
root = 151838 delta = -60061
root = 211899 delta = -30030
root = 241929 delta = -14978
root = 256907 delta = -7452
root = 264359 delta = -3726
root = 268085 delta = -1827
root = 269912 delta = -876
root = 270788 delta = -438
root = 271226 delta = -182
...

The output from the Linux version is different but still equally wrong
after the first output line.

I would have expected the output to be something like

root = 32768 delta = 1125
root = 31643 delta = 20
31623

(which is what I get when I run it with elk.)

Can someone explain what the right answer should be?

Ray
Received on Tue Feb 13 1996 - 17:13:26 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST