Java Utililty Methods Double Number Equal

List of utility methods to do Double Number Equal

Description

The list of methods to do Double Number Equal are organized into topic(s).

Method

booleandoubleEqual(double d1, double d2)
Returns whether the two specified double value are equal.
double absDiff = Math.abs(d1 - d2);
return absDiff < FP_EQUALITY_THRESHOLD;
booleandoubleEqual(double d1, double d2, double delta)
double Equal
if (delta < 0) {
    throw new IllegalArgumentException("Delta for doubleEqual cannot be < 0: " + delta);
double diff = d1 - d2;
return ((diff >= 0) && (diff < delta)) || ((diff < 0) && (diff > -delta));
booleandoubleEqual(double v1, double v2)
double Equal
return (Double.isNaN(v1) && Double.isNaN(v2)) || Math.abs(v1 - v2) < epsilon;
booleandoubleEquality(double v1, double v2, double epsilon)
a pseudo-equality check for doubles
return Math.abs(v1 - v2) < epsilon;
booleandoubleEquals(double a, double b)
Implements the semantics of Double#equals(Object) for two primitive doubles.
return Double.doubleToLongBits(a) == Double.doubleToLongBits(b);
booleandoubleEquals(double a, double b)
double Equals
return doubleEquals(a, b, DEFAULT_EPSILON);
booleandoubleEquals(double a, double b)
Returns true if the two doubles are within a small epsilon of each other.
return Math.abs(a - b) < epsilon;
booleandoubleEquals(double d1, double d2)
double Equals
return Double.compare(d1, d2) == 0;
booleandoubleEquals(Double d1, Double d2)
Check if the two Double values are equal by checking that the absolute value between them is less than 0.01
return Math.abs(d1 - d2) <= 0.01;
booleandoubleEquals(double d1, double d2, double epsilon)
double Equals
return Math.abs(d1 - d2) <= epsilon;