fork download
  1. #include <iostream>
  2. #include <limits>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. cout << (numeric_limits<double>::is_iec559 ? "IEEE 754 encoding":"unknown encoding") <<endl;
  8. cout << (numeric_limits<double>::is_bounded ? "bounded":"not bounded") <<endl;
  9. cout << "Max: "<<numeric_limits<double>::max()<<endl;
  10. cout << "-Max: "<<-numeric_limits<double>::max()<<endl;
  11. cout << "Lowest:" << numeric_limits<double>::lowest()<<endl;
  12. float a = 0.15 + 0.15;
  13. float b = 0.1 + 0.2;
  14. float diff = std::abs(a - b);
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
IEEE 754 encoding
bounded
Max:   1.79769e+308
-Max:  -1.79769e+308
Lowest:-1.79769e+308