[gambit-list] How emulate #e using inexact->exact or something?
Bakul Shah
bakul at bitblocks.com
Tue Dec 24 14:50:49 EST 2013
On Tue, 24 Dec 2013 19:54:54 +0100 Mikael <mikael.rcv at gmail.com> wrote:
> Ah - http://www.binaryconvert.com/result_double.html?decimal=048046051clarifi
> es
> that
>
> 0.3 is represented internally as 2.99999999999999988897769753748E-1 ,
It is /approximated/ as a sum of some (negative) powers of 2 (as
that is the best you can do with binary floating point formats).
> (- 3/10 (inexact->exact 0.3))
1/90071992547409920
> so this is what inexact->exact converts to 5404319552844595/18014398509481984.
>
>
> I guess this makes a strong case for representing fixed-point numbers as
> integers.
In general the answer depends what is more important in an
application: accuracy, precision, range, exactness, speed,
space use, portability etc. Most GPUs for example don't
support double precision, while Maxima can use arbitrary
precision floats. Financial calculations mostly use (or used
to use) decimal arithmetic.
In any case for this you can already use rational numbers in
gambit.
> (exact? 0.3)
#f
> (exact? 3/10)
#t
More information about the Gambit-list
mailing list