samedi 3 janvier 2015

Strange behavior with the lisp random function

Is there anyone can explain to me the following behavior concerning the random function with the float numbers and how to get rid of this:



CL-USER> (loop for i from 1 to 20 collect (* 0.1 (random 100)))

;; with sbcl ...
(9.2 4.4 9.5 0.5 9.7 5.8 4.3 9.900001 3.7 6.8 2.6000001 9.5 1.6 8.900001 3.3 1.7 5.1 5.5 4.2000003 8.2)

;; with closure ...
(7.7000003 7.2000003 1.7 5.6 7.5 2.2 5.0 7.6 2.0 4.9 2.9 1.6 0.4 6.1 3.3 7.1 8.7 6.5 5.6 9.2)




Aucun commentaire:

Enregistrer un commentaire