Last active
December 16, 2015 13:39
-
-
Save Protonk/5443572 to your computer and use it in GitHub Desktop.
Hey guys, I totally fixed that floating point comparison problem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var approx = function(a, b, eps) { | |
// http://en.wikipedia.org/wiki/Machine_epsilon | |
eps = eps || 5e-16; | |
return |a - b| < eps; | |
} | |
approx(0.1 * 0.2, 0.02) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment