On Tue, Jan 06, 2009 at 09:20:32PM -0600, Kevin Beranek wrote:
> Below is a test case followed by some sample output.  One interesting
> thing to note about the output is that (number->string 99 2) produced
> two different values (2 and 75).  Also of note is that I've tried
> various constructions of the following code with let statements at
> different levels, using let vs. set! in different places and different
> methods of looping but the bug remains in every combination I've tried.

I tried it in my Chicken 3 (3.0.1) and it failed there too, then I tried
the following small alteration:

(use srfi-13)

(let ((i 0) (val 0) (binary-val 0) (invalid #f) (j 0) (c 0))

  (do ((i 0 (+ i 1))) ((= i 5000))
    (set! val (random 100))
    (set! binary-val (number->string val 2))
    (set! invalid (not (string-every (char-set #\0 #\1) binary-val)))

    (if invalid
      (printf "(number->string ~a 2) = ~a\n" val binary-val))))

This works for me, so there's more to it than just "number->string is
not working".

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: pgpUfbFH3D2iY.pgp
Description: PGP signature

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to