Ah - http://www.binaryconvert.com/result_double.html?decimal=048046051clarifies that
0.3 is represented internally as 2.99999999999999988897769753748E-1 ,
so this is what inexact->exact converts to 5404319552844595/18014398509481984 .
I guess this makes a strong case for representing fixed-point numbers as integers.
2013/12/24 Bakul Shah bakul@bitblocks.com
On Tue, 24 Dec 2013 18:18:03 +0100 Mikael mikael.rcv@gmail.com wrote:
Wait, just curious, what is the actual FP 64bit representation of 0.3 and why does it turn out differently like this?
(and (exact->inexact 5404319552844595/18014398509481984) become .3 rather than 0.299[something] or 0.3000[something])
This may give you a hint:
$ bc obase=2 5404319552844595 10011001100110011001100110011001100110011001100110011 18014398509481984 1000000000000000000000000000000000000000000000000000000 ^D
Or see http://en.wikipedia.org/wiki/Double-precision_floating-point_format