This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Trouble with floating point constants in printf and different versions of gcc
- From: Momchil Ivanov <momchil at xaxo dot eu>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Momchil Ivanov <momchil at xaxo dot eu>, gcc-help at gcc dot gnu dot org
- Date: Mon, 17 Oct 2011 10:19:55 +0200
- Subject: Re: Trouble with floating point constants in printf and different versions of gcc
- References: <86pqhycucg.wl%momchil@xaxo.eu> <mcrobxh4q9v.fsf@coign.corp.google.com>
At Sat, 15 Oct 2011 19:35:40 -0700,
Ian Lance Taylor wrote:
>
> Momchil Ivanov <momchil@xaxo.eu> writes:
>
> > gcc 4.5 and 4.6 produce different output when compiled with -std=c99 than gcc 4.2 and 4.4.
>
> In gcc 4.5 and up -std=c99 implies -fexcess-precision=standard, q.v.
>
> Ian
Thank you for the tip, but I still don't understand why the following produces different output for both floats when compiled with -fexcess-precision=standard:
#include <stdio.h>
int
main(int argc, char *argv[])
{
float a = 268517138.f;
printf(" 268517138.f = %f\t%f\n", 268517138.f, a);
return 0;
}
output with -fexcess-precision=standard:
268517138.f = 268517138.000000 268517152.000000
output without -fexcess-precision=standard:
268517138.f = 268517152.000000 268517152.000000
Regards,
Momchil