[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accuracy of floating point computation in MCL



There seems to be a pervasive and important error in floating point
calculations in MCL.

Some examples:

? (loop for i from 0.0 to 1.0 by 0.1 collect i)
(0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.7999999999999999 0.8999999999999999 0.9999999999999999)
? 
?
? (- .3 3/10)
-1.111307226797642E-17
? 

And my favourite is 

? (> 3/10 .3)
T

Imagine the consequences!

Note however that 
(- 1/2 .5) yields 0.0
as does
(- 1/8 .125)

As our application here depends *critically* on *accurate*
numerical calculations we were wondering exactly how we could get MCL
to "do the right thing"!