Date: Fri, 3 Dec 2004 09:53:02 +0100 From: "Florian Hengstberger" <e0025265@student.tuwien.ac.at> To: FreeBSD mailinglist <freebsd-questions@freebsd.org> Subject: Floating Point Arithmetic Message-ID: <i8520e.z7poi7@webmail.tuwien.ac.at>
next in thread | raw e-mail | index | archive | help
Hi!
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
is 2**(8*8).
(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???
Thanks
Florian
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!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?i8520e.z7poi7>
