Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Dec 2004 00:11:17 +1030
From:      Malcolm Kay <malcolm.kay@internode.on.net>
To:        "Florian Hengstberger" <e0025265@student.tuwien.ac.at>, FreeBSD mailinglist <freebsd-questions@freebsd.org>
Subject:   Re: Floating Point Arithmetic
Message-ID:  <200412040011.17130.malcolm.kay@internode.on.net>
In-Reply-To: <i8520e.z7poi7@webmail.tuwien.ac.at>
References:  <i8520e.z7poi7@webmail.tuwien.ac.at>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 3 Dec 2004 07:23 pm, Florian Hengstberger wrote:
> 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???

Just think about it. If you have an integer power of two all the
discarded significant bits were zero anyway so the representation 
is exact.

But try 2**1000-1

Malcolm




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200412040011.17130.malcolm.kay>