Package org.kiwiproject.base
Class KiwiDoubles
java.lang.Object
org.kiwiproject.base.KiwiDoubles
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault tolerance to use for comparisons when not explicitly specified. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareClose(double value1, double value2) Return true if value1 is close to value2, within the default tolerance.static booleanareClose(double value1, double value2, double tolerance) Return true if value1 is close to value2, within the given tolerance.static booleanareEqual(double value1, double value2) Return true if value1 is numerically equal to value2.static booleanareNotEqual(double value1, double value2) Return true if value1 is not numerically equal to value2.static booleanisCloseToZero(double value) Return true if value is close to zero, within the default tolerance.static booleanisCloseToZero(double value, double tolerance) Return true if value is close to zero, using the given tolerance.static booleanisNotZero(double value) Return true if value is not exactly equal to zero.static booleanisZero(double value) Return true if value is exactly equal to zero.
-
Field Details
-
DEFAULT_FUZZY_EQUALS_TOLERANCE
public static final double DEFAULT_FUZZY_EQUALS_TOLERANCEDefault tolerance to use for comparisons when not explicitly specified.- See Also:
-
-
Method Details
-
isZero
public static boolean isZero(double value) Return true if value is exactly equal to zero.- Parameters:
value- the value to check- Returns:
- true if the value is zero
- See Also:
-
isNotZero
public static boolean isNotZero(double value) Return true if value is not exactly equal to zero.- Parameters:
value- the value to check- Returns:
- true if the value is not zero
- See Also:
-
isCloseToZero
public static boolean isCloseToZero(double value) Return true if value is close to zero, within the default tolerance.- Parameters:
value- the value to check- Returns:
- true if the value is close to zero using the
DEFAULT_FUZZY_EQUALS_TOLERANCE - See Also:
-
DoubleMath.fuzzyEquals(double, double, double)DEFAULT_FUZZY_EQUALS_TOLERANCE
-
isCloseToZero
public static boolean isCloseToZero(double value, double tolerance) Return true if value is close to zero, using the given tolerance.- Parameters:
value- the value to checktolerance- how far away the value can be from zero while still considered equal to zero- Returns:
- true if the value is close to zero
- See Also:
-
DoubleMath.fuzzyEquals(double, double, double)
-
areEqual
public static boolean areEqual(double value1, double value2) Return true if value1 is numerically equal to value2.- Parameters:
value1- the first value to comparevalue2- the second value to compare- Returns:
- true if value1 equals value2
- See Also:
-
areNotEqual
public static boolean areNotEqual(double value1, double value2) Return true if value1 is not numerically equal to value2.- Parameters:
value1- the first value to comparevalue2- the second value to compare- Returns:
- true if value1 does not equal value2
- See Also:
-
areClose
public static boolean areClose(double value1, double value2) Return true if value1 is close to value2, within the default tolerance.- Parameters:
value1- the first value to comparevalue2- the second value to compare- Returns:
- true if value1 is close to value2 using the
DEFAULT_FUZZY_EQUALS_TOLERANCE - See Also:
-
DoubleMath.fuzzyEquals(double, double, double)DEFAULT_FUZZY_EQUALS_TOLERANCE
-
areClose
public static boolean areClose(double value1, double value2, double tolerance) Return true if value1 is close to value2, within the given tolerance.- Parameters:
value1- the first value to comparevalue2- the second value to comparetolerance- how far away the values can be from each other while still considered equal- Returns:
- true if value1 is close to value2 using the
DEFAULT_FUZZY_EQUALS_TOLERANCE - See Also:
-
DoubleMath.fuzzyEquals(double, double, double)
-