[gambit-list] How emulate #e using inexact->exact or something?

Mikael mikael.rcv at gmail.com
Tue Dec 24 13:54:54 EST 2013


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 at bitblocks.com>

> On Tue, 24 Dec 2013 18:18:03 +0100 Mikael <mikael.rcv at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20131224/e6076842/attachment.htm>


More information about the Gambit-list mailing list