commonMain.korlibs.math.IsAlmostEquals.kt Maven / Gradle / Ivy
package korlibs.math
import kotlin.math.*
interface IsAlmostEquals {
fun isAlmostEquals(other: T, epsilon: Double = 0.000001): Boolean
}
interface IsAlmostEqualsF {
fun isAlmostEquals(other: T, epsilon: Float = 0.0001f): Boolean
}
fun Float.isAlmostEquals(other: Float, epsilon: Float = 0.000001f): Boolean = (this - other).absoluteValue < epsilon
fun Double.isAlmostEquals(other: Double, epsilon: Double = 0.000001): Boolean = (this - other).absoluteValue < epsilon
© 2015 - 2025 Weber Informatics LLC | Privacy Policy