fork(1) download
  1. #include <cfloat>
  2. #include <cmath>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. auto classify(double x) {
  7. switch (std::fpclassify(x)) {
  8. case FP_INFINITE: return "Inf";
  9. case FP_NAN: return "NaN";
  10. case FP_NORMAL: return "normal";
  11. case FP_SUBNORMAL: return "subnormal";
  12. case FP_ZERO: return "zero";
  13. default: return "unknown";
  14. }
  15. }
  16.  
  17. int main() {
  18. double x = DBL_MIN;
  19. cout << "DBL_MIN is " << classify(x) << endl;
  20. cout << (x > 0) << endl;
  21. cout << "DBL_MIN * DBL_MIN is " << classify(x * x) << endl;
  22. cout << (x * x > 0) << endl;
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
DBL_MIN is normal
1
DBL_MIN * DBL_MIN is zero
0