Floating Point Arithmetic
e0025265 at student.tuwien.ac.at
Fri Dec 3 00:53:07 PST 2004
I tried to figure out the capability of double:
so I calculated
d=2**n (with a for-loop)
increasing n step by step.
Of course I get a floating point exception when
d is bigger than 10**308.
But what makes me wondering is the fact that printing
printf("%lf",d) gives me the full range of numbers!
Calculating 2**1000 and I got the correct number
with all (!!) digits. (I cross-checked the digits with python.)
This is unexpected because sizeof(double) on my machine is 8,
and so I thought that the limit for the correct representation
(Actually the limit should be - meeting the IEEE standard -
2**52, the space reserved for representing the fraction of
a floating point number.)
Anyway I can calculate 2**n, with n up to 1023 exact.
Why is this???
PS: I even had a look at the assembly code, for printf
the %lf and than twice 32bit a pushed on the stack before
calling printf. Still not enough memory to represent 2**1000!
More information about the freebsd-questions