Package com.myscript.util
Class Numbers
java.lang.Object
com.myscript.util.Numbers
Set of utility functions to compare floating point values.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic int
hashCode
(double x) Returns a hash code for this Double object.static int
hashCode
(float x) Returns a hash code for a Float object.static boolean
isNear
(double x, double y) Compares two values and returns `true` if they are near each other.static boolean
isNear
(double x, double y, double absolute_tolerance, double relative_tolerance) Compares two values and returns `true` if they are near each other.static boolean
isNear
(float x, float y) Compares two values and returns `true` if they are near each other.static boolean
isNear
(float x, float y, float absolute_tolerance, float relative_tolerance) Compares two values and returns `true` if they are near each other.
-
Field Details
-
FLT_EPSILON
public static final float FLT_EPSILON- See Also:
-
DBL_EPSILON
public static final double DBL_EPSILON- See Also:
-
-
Method Details
-
isNear
public static boolean isNear(float x, float y, float absolute_tolerance, float relative_tolerance) Compares two values and returns `true` if they are near each other.- Parameters:
x
- the first value to compare.y
- the second value to compare.absolute_tolerance
- the absolute tolerance for the comparison.relative_tolerance
- the relative tolerance for the comparison.- Returns:
- `true` if `x` and `y` are near, false otherwise.
-
isNear
public static boolean isNear(float x, float y) Compares two values and returns `true` if they are near each other. Tolerance is the the difference between 1.0 and the next representable value of the given floating-point type.- Parameters:
x
- the first value to compare.y
- the second value to compare.- Returns:
- `true` if `x` and `y` are near, false otherwise.
-
isNear
public static boolean isNear(double x, double y, double absolute_tolerance, double relative_tolerance) Compares two values and returns `true` if they are near each other.- Parameters:
x
- the first value to compare.y
- the second value to compare.absolute_tolerance
- the absolute tolerance for the comparison.relative_tolerance
- the relative tolerance for the comparison.- Returns:
- `true` if `x` and `y` are near, false otherwise.
-
isNear
public static boolean isNear(double x, double y) Compares two values and returns `true` if they are near each other. Tolerance is the the difference between 1.0 and the next representable value of the given double-point type.- Parameters:
x
- the first value to compare.y
- the second value to compare.- Returns:
- `true` if `x` and `y` are near, false otherwise.
-
hashCode
public static int hashCode(float x) Returns a hash code for a Float object.- Parameters:
x
- the float to hash.- Returns:
- a hash code value for this object
-
hashCode
public static int hashCode(double x) Returns a hash code for this Double object.- Parameters:
x
- the Double to hash.- Returns:
- a hash code value for this object.
-