[Cfp-interest] FLT_EVAL_METHOD & FP constants

Fred J. Tydeman tydeman at tybor.com
Fri Jul 14 18:46:11 PDT 2017


On Tue, 11 Jul 2017 13:05:43 -0500 Rajan Bhakta wrote:
>
>    Fred: Summarize what goes wrong for FLT_EVAL_METHOD for the things 
>Fred has tested.

I remembered all the problems the compilers have with DEC_EVAL_METHOD.
I mis-remembered about FLT_EVAL_METHOD.  gcc and sun studio do the
right thing for FP constants (as per the C standard).  clang gets it 
wrong for the x87 FPU.

Intel x86 CPU / x87 FPU / sse2 FPU

32-bit OS (Linux)
  gcc for x87: FLT_EVAL_METHOD is 2
    constants are done as long double
  gcc for sse2: FLT_EVAL_METHOD is 0
    constants are done as type
  clang for x87: FLT_EVAL_METHOD is 2
    constants are done as type (which is wrong)
  clang for sse2: FLT_EVAL_METHOD is 0
    constants are done as type

64-bit OS (Linux)
  gcc for x87: FLT_EVAL_METHOD is 2
    constants are done as long double
  gcc for sse2: FLT_EVAL_METHOD is 0
    constants are done as type
  clang for x87: FLT_EVAL_METHOD is ?
    will not compile
  clang for sse2: FLT_EVAL_METHOD is 0
    constants are done as type

??-bit OS (Solaris 11.3)
  Sun Studio 12.4 for x87: FLT_EVAL_METHOD is 2
    constants are done as long double
  Sun Studio 12.4 for sse2: FLT_EVAL_METHOD is 0
    constants are done as type

But, 
  float y = 1.1e75f;
does NOT raise overflow (which is wrong) when FLT_EVAL_METHOD is 2
(see F.8.5).
(Test t0080000)

Also,
 int rc = fesetround( FE_UPWARD );
 double d = (float)DBL_MIN;     /* should NOT be zero */
 float  f = (float)DBL_MIN;     /* should NOT be zero */
fails (because casts of constants are done at translation time).
(Test t0310200)


---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list