Skip to content

Instantly share code, notes, and snippets.

@Fiona-J-W
Created June 30, 2014 19:17
Show Gist options
  • Save Fiona-J-W/b4eb6a80f84ed5d1ac56 to your computer and use it in GitHub Desktop.
Save Fiona-J-W/b4eb6a80f84ed5d1ac56 to your computer and use it in GitHub Desktop.
rounding-error
#include <cmath>
#include <iostream>
int main() {
double num1 = 1.4126572077159485e+23;
double num2 = 1.4126572077159483546e+23;
double num3 = std::nexttoward(num2, num1);
std::cout << (num3 > num2) << '\n';
}
@Fiona-J-W
Copy link
Author

If compiler and stdlib work correctly, this should print “1”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment