[plt-scheme] What's the deal with inexact numbers?

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Mar 5 18:09:28 EST 2007

Todd O'Bryan skrev:
> I've noticed a strange inconsistency with respect to inexact numbers.
> The values of e and pi in HtDP Beginning Student are accurate to 15
> decimal places:
>> e
> #i2.718281828459045

 > (string-length "2718281828459045")

>> pi
> #i3.141592653589793

 > (string-length "3141592653589793")

Floating point numbers in MzScheme are "doubles". They consist
of a sign bit, a mantissa and an exponent. The "digits" are
stored in the mantissa and the exponent determines the scale.
The important thing to note is that digits before and after
the decimal point aren't stored separately. So if there
is many digits before the decimal point (eh - binary point?)
then there is only room for a few after the point.

 > (sqrt 2000000000000000000000)

Jens Axel Søgaard

Posted on the users mailing list.