Skip to content

Instantly share code, notes, and snippets.

@tlylt
Created September 25, 2020 08:45
Show Gist options
  • Save tlylt/72f08629bfbf3502d3ff1952d3cba7f7 to your computer and use it in GitHub Desktop.
Save tlylt/72f08629bfbf3502d3ff1952d3cba7f7 to your computer and use it in GitHub Desktop.
Compare two double in Java
boolean closeEnough(double a, double b) {
double tolerance = 1E-4;
return Math.abs(a-b) < tolerance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment