Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created January 21, 2015 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/e7a042465eba4853cdc5 to your computer and use it in GitHub Desktop.
Save shigemk2/e7a042465eba4853cdc5 to your computer and use it in GitHub Desktop.
def ~=(x: Double, y: Double, precision: Double) = {
if ((x - y).abs < precision) true else false
}
val a = 0.3
val b = 0.1 + 0.2001
println(~=(a, b, 0.0001))
println(~=(b, a, 0.0001))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment