fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cfloat>
  4.  
  5. int main()
  6. {
  7. double d = 1'000'000;
  8. double nextEpsilon = d + DBL_EPSILON;
  9. double next = nextafter(d, 2 * d);
  10.  
  11. std::cout.precision(17);
  12. std::cout << d << std::endl;
  13. std::cout << nextEpsilon << std::endl;
  14. std::cout << next << std::endl;
  15.  
  16. if (d == nextEpsilon) {
  17. std::cout << "nextEpsilon is identical\n";
  18. }
  19. if (d == next) {
  20. std::cout << "next is identical\n";
  21. }
  22. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1000000
1000000
1000000.0000000001
nextEpsilon is identical