(coerce .2 'double-float)
it returns on Allegro 8.1 running under windows vista 32 bit
0.22200000286102295d0
Why is the new number different??? What's going on

Code: Select all
CL-USER> (integer-decode-float .2d0)
7205759403792794
-55
1
CL-USER> (integer-decode-float .2)
13421773
-26
1
Code: Select all
CL-USER> (/ 7205759403792794 13421773)
7205759403792794/13421773
Code: Select all
CL-USER> (integer-decode-float (coerce .2 'double-float))
7205759511166976
-55
1
CL-USER> (/ 7205759511166976 13421773)
536870912
Huh, strange that I completely missed your typo earlier, reading it as the above behavior (as you've corrected it)Harnon wrote:Sorry. (coerce .2 'double-float) produces
0.20000000298023224d0
(* .2 1d0) produces 0.20000000298023224d0
(* .2d0 .1d0) produces
0.020000000000000004d0
I think I will just stick to the float version of the c library. Thanks for the explanation!
Is not particularly useful in this actual situation. The issue isn't whether or not you can represent 2/10 in both representations, but how you choose to map the smaller representation to the larger one, which obviously cannot be done bijectively. In this context there is nothing special about "0.2d0" compared to "0.20000000298023224d0", they both map to 0.2 in single precision.(and double-floats can store all single-floats without loss)
Code: Select all
CL-USER> (float .2 1d0)
0.20000000298023224d0
CL-USER> (float (float .2 1d0) 1.0)
0.2
CL-USER> (float .2d0 1.0)
0.2