Posted to tcl by sebres at Mon Jun 24 17:08:04 GMT 2019view raw
- $ echo '
- > #include <float.h>
- > #include <math.h>
- > #include <stdio.h>
- > const char *cs(double x) { switch(fpclassify(x)) {
- > case FP_INFINITE: return "Inf";
- > case FP_NAN: return "NaN";
- > case FP_NORMAL: return "normal";
- > case FP_SUBNORMAL: return "subnormal";
- > case FP_ZERO: return "zero";
- > default: return "unknown";
- > }}
- > int main()
- > {
- > printf("%s: fpclassify: %d -- %s\n",
- > sizeof(void *) == 8 ? "x64" : "x86", fpclassify(1e-314), cs(1e-314));
- > return 0;
- > }
- > // ' > test.c; gcc -O2 -Wall -Wextra test.c -o test; ./test
- # results:
- x64: fpclassify: 17408 -- subnormal
- x86: fpclassify: 1024 -- normal