Created
March 9, 2015 14:09
-
-
Save cevaris/bc331cbe970b03816c6b to your computer and use it in GitHub Desktop.
Golang float64 equality esitimation
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 EPSILON float64 = 0.00000001 | |
func floatEquals(a, b float64) bool { | |
if ((a - b) < EPSILON && (b - a) < EPSILON) { | |
return true | |
} | |
return false | |
} |
var EPSILON float64 = 0.00000001
func floatEquals(a, b float64) bool {
return math.Abs(a - b) < EPSILON
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not