Re: FLT_EVAL_METHOD vs fexcess-precision

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 1 Sept 2023 at 11:14, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
>
> On Fri, 1 Sept 2023 at 10:57, Mathieu Malaterre via Gcc-help
> <gcc-help@xxxxxxxxxxx> wrote:
> >
> > Hi all,
> >
> > I am reading a previous post from Pascal Cuoq(*), and it seems things
> > have changed quite a bit in GCC nowadays. I fail to understand how
> > FLT_EVAL_METHOD relates to fexcess-precision. Did I miss something?
>
> See https://gcc.gnu.org/gcc-13/changes.html#cxx

Oh but you're asking about C, which hasn't changed in a while.

I'm not sure what your question is then. FLT_EVAL_METHOD tells you
what precision is used for floating-point constants and arithmetic,
and -fexcess-precision says whether GCC strictly follows the
standard's rules about when those excess precision bits are used.

If FLT_EVAL_METHOD==2 then float and double constants are represented
in 80-bit long double format, and arithmetic operations are done in
80-bit long double format. To remove the excess precision and get a
32-bit float or 64-bit double you need to use an explicit cast to
float or double.

If FLT_EVAL_METHOD==0 then there are no excess precision bits, and so
-fexcess-precision makes no difference.

Does that answer the question?


>
> >
> > ---
> >
> > Here is what I see on my Debian/sid/i386 system:
> >
> >  % gcc -O2 -fexcess-precision=fast   m.c && ./a.out
> > float eps = 1.192093e-07
> > 2
> >
> > while:
> >
> >  % gcc -O2 -fexcess-precision=standard   m.c && ./a.out
> > float eps = 1.084202e-19
> > 2
> >
> > with:
> >
> >  % cat m.c
> > #include <stdio.h>
> > #include <float.h>
> >
> > int main(void)
> > {
> >     float floatEps = 1;
> >
> >     while (1 + floatEps / 2 != 1)
> >         floatEps /= 2;
> >
> >     printf("float eps = %e\n", floatEps);
> >     printf("%d\n", FLT_EVAL_METHOD);
> > }
> >
> > For reference:
> >
> >  % gcc --version
> > gcc (Debian 13.2.0-2) 13.2.0
> >
> > (*) https://stackoverflow.com/a/16064515/136285
> > --
> > Mathieu



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux