I think that probably there is a bug with the macro fpclassify(). The following
program classifies a 'double subnormal' number as a 'normal' one (maybe the
value it is seen by the macro as a 'long double').
#include <math.h> #include <float.h> #include <stdio.h> int main(void) { double x = DBL_MIN/1024.0; long double z = LDBL_MIN/1024.0; printf("x == %a\n\nclass x == %X\n\nclass z == %X\n", x, fpclassify(x), fpclassify(z)); }
My compiler is GCC 4.7.2 on MinGW, under Windows 7 (running just in CMD.EXE).
The compiler option is just: -std=c99. (Anyway, without command line options I
have found the same results).
I have FLT_EVAL_METHOD == 2.
The output I have obtained is:
x == 0x8p-1035 class x == 400 class z == 4400
Comments:
It seems that fpclassify(x) have not recognized that x has type 'double'.
argentinator
2013-02-20
The source code is not properly shown in the 1st message,
so I add an atachment.
Keith Marshall
2013-02-20
Diff:
--- old +++ new @@ -3,6 +3,7 @@ value it is seen by the macro as a 'long double'). ---------------------------------------------------------------- +~~~~ #include <math.h> #include <float.h> #include <stdio.h> @@ -12,6 +13,7 @@ printf("x == %a\n\nclass x == %X\n\nclass z == %X\n", x, fpclassify(x), fpclassify(z)); } +~~~~ ---------------------------------------------------------------- My compiler is GCC 4.7.2 on MinGW, under Windows 7 (running just in CMD.EXE). @@ -22,11 +24,13 @@ The output I have obtained is: -------------------------------------------------------------- +~~~~ x == 0x8p-1035 class x == 400 class z == 4400 +~~~~ -------------------------------------------------------------- Comments:
argentinator
2013-02-20
Keith, thank you for fixing my original message.
Earnie Boyd
2013-02-20
Earnie Boyd
2013-02-20
I'll have to take a look at the implementation. I'm planning a 4.0 release soon which is why I've marked this for 4.1.