fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <limits>
  4.  
  5. int main() {
  6. auto m = std::numeric_limits<float>::max();
  7. std::cout << "float max: " << m << "\n";
  8. auto x = std::nextafter(m, 0.0f);
  9. std::cout << "biggest value less than max: " << x << "\n";
  10. auto d = m - x;
  11. std::cout << "the difference: " << d << "\n";
  12. return 0;
  13. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
float max: 3.40282e+38
biggest value less than max: 3.40282e+38
the difference: 2.02824e+31