[plt-scheme] What's the deal with inexact numbers?
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")
16
>> pi
> #i3.141592653589793
> (string-length "3141592653589793")
16
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)
44721359549.9958
--
Jens Axel Søgaard