Skip to content

Instantly share code, notes, and snippets.

@zhuker
Created March 8, 2019 22:03
Show Gist options
  • Save zhuker/b0b398a4d1bc3e8c25c51090a5ee7a7f to your computer and use it in GitHub Desktop.
Save zhuker/b0b398a4d1bc3e8c25c51090a5ee7a7f to your computer and use it in GitHub Desktop.
/**
* Compare two {@code double} values
* @param other <i>double</i> value to compare to
* @param epsilon precision
* @return {@code true} if the two values are equal
*/
fun Double.eq(other: Double, epsilon: Double = 0.00000001) = Math.abs(this - other) < epsilon
fun Float.eq(other: Float, epsilon: Float = 0.00000001f) = Math.abs(this - other) < epsilon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment