Posted to tcl by sebres at Mon Jun 24 17:08:04 GMT 2019view raw

  1. $ echo '
  2. > #include <float.h>
  3. > #include <math.h>
  4. > #include <stdio.h>
  5. > const char *cs(double x) { switch(fpclassify(x)) {
  6. > case FP_INFINITE: return "Inf";
  7. > case FP_NAN: return "NaN";
  8. > case FP_NORMAL: return "normal";
  9. > case FP_SUBNORMAL: return "subnormal";
  10. > case FP_ZERO: return "zero";
  11. > default: return "unknown";
  12. > }}
  13. > int main()
  14. > {
  15. > printf("%s: fpclassify: %d -- %s\n",
  16. > sizeof(void *) == 8 ? "x64" : "x86", fpclassify(1e-314), cs(1e-314));
  17. > return 0;
  18. > }
  19. > // ' > test.c; gcc -O2 -Wall -Wextra test.c -o test; ./test
  20.  
  21.  
  22. # results:
  23.  
  24. x64: fpclassify: 17408 -- subnormal
  25. x86: fpclassify: 1024 -- normal
  26.