On Tue, Jan 25, 2022 at 09:05:55AM +0100, FX wrote: > > > Got the following in testsuite/gfortran/gfortran.log > > > > NaN 7FFFA000000000000000 > > NaN 7FFFC000000000000000 > > NaN 7FFFA000000000000000 > >
Could be a problem with __builtin_nansl(). #include <stdio.h> #include <stdint.h> int main(void) { union { float x; uint32_t i; } f; union { double x; uint64_t i; } d; union { long double x; uint64_t i[2]; } l; printf("Quiet NaN\n"); f.x = __builtin_nanf(""); printf("%f %x\n", f.x, f.i); d.x = __builtin_nan(""); printf("%lf %lx\n", d.x, d.i); l.x = __builtin_nanl(""); printf("%Lf %lx%lx\n", l.x, l.i[1], l.i[0]); printf("Signaling NaN\n"); f.x = __builtin_nansf(""); printf("%f %x\n", f.x, f.i); d.x = __builtin_nans(""); printf("%lf %lx\n", d.x, d.i); l.x = __builtin_nansl(""); printf("%Lf %lx%lx\n", l.x, l.i[1], l.i[0]); return 0; } % ~/work/x/bin/gcc -o z a.c && ./z Quiet NaN nan 7fc00000 nan 7ff8000000000000 nan 7fffc000000000000000 Signaling NaN nan 7fa00000 nan 7ff4000000000000 nan 7fffa000000000000000 s bit is 0, so the 7 is correct. The width of the exponet is w = 8, 11, and 15 bits for float, double, and long double. The first significant bit, d, is then 9, 12, and 16. s|----w---|d 7fc --> 0111 1111 1100 7fa --> 0111 1111 1010 s|-----w-----| d 7ff8 --> 0111 1111 1111 1000 7ff4 --> 0111 1111 1111 0100 s|-------w--------| d 7fffc -> 0111 1111 1111 1111 1100 <-- should be 7fff8? 7fffa -> 0111 1111 1111 1111 1010 <-- should be 7fff4? What does linux/darwin show? -- Steve