This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Floating point: just 20 digits of precision
On 11/26/2010 01:25 PM, Elias Gabriel Amaral da Silva wrote:
> This simple program
>
> #include <stdio.h>
> int main()
> {
> long double c, d, e;
> c = 1.0/7.0;
> d = 1.0; d /= 7.0;
> e = 1.0L/7.0L;
> printf("sizeof(7.0) = %u, sizeof(7.0L) = %u\n",sizeof(7.0),sizeof(7.0L));
> printf("%3.60Lf %3.60Lf\n", c, c*7.0);
> printf("%3.60Lf %3.60Lf\n", d, d*7.0);
> printf("%3.60Lf %3.60Lf\n", e, e*7.0);
>
> return 0;
> }
>
> Seems to yield the same precision for long double on both ia32 and
> amd64 - that is, just 20 digits. This seems too few, looking there:
>
> http://en.wikipedia.org/wiki/IEEE_754-2008#Basic_formats
Long double isn't one of the basic formats, it's an extended precision
format. See Section 3.7 of IEEE-754-2008.
http://en.wikipedia.org/wiki/Extended_precision
Andrew.