DoubleEquivalence

open class DoubleEquivalence(val epsilon: Double = DBL_EPSILON)(source)

A class that provides methods for comparing double values with a specified precision.

This class is used to determine the equality and order of double values while considering floating-point precision errors.

Constructors

Link copied to clipboard
constructor(epsilon: Double = DBL_EPSILON)

Properties

Link copied to clipboard

The precision threshold for comparing double values. Defaults to DBL_EPSILON.

Functions

Link copied to clipboard
open fun compare(a: Double, b: Double): Int

Compares two double values.

Link copied to clipboard
fun eq(a: Double, b: Double): Boolean

Indicates if given double values are equal.

Link copied to clipboard

Checks if a double value is equal to zero.

Link copied to clipboard
fun gt(a: Double, b: Double): Boolean

Checks if value a is strictly greater than value b.

Link copied to clipboard
fun gte(a: Double, b: Double): Boolean

Checks if value a is greater than or equal to value b.

Link copied to clipboard
fun lt(a: Double, b: Double): Boolean

Checks if value a is strictly smaller than value b.

Link copied to clipboard
fun lte(a: Double, b: Double): Boolean

Checks if value a is smaller than or equal to value b.

Link copied to clipboard

Returns the sign of a double value.