Package org.vast.util
Class NumberUtils
java.lang.Object
org.vast.util.NumberUtils
Utility math functions
- Since:
- Apr 6, 2017
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
exactEquals
(double d1, double d2) Exact double equality checkstatic boolean
exactEquals
(float f1, float f2) Exact float equality checkstatic boolean
Checks that text is a numberstatic boolean
isNumericExp
(String text) Checks that text is a number allowing for exponentstatic boolean
ulpEquals
(double d1, double d2) Checks that double arguments are within one ULP of each otherstatic boolean
ulpEquals
(float f1, float f2) Checks that float arguments are within one ULP of each other
-
Method Details
-
ulpEquals
public static boolean ulpEquals(float f1, float f2) Checks that float arguments are within one ULP of each other- Parameters:
f1
-f2
-- Returns:
- true if both numbers are within 1 ULP, false otherwise
-
ulpEquals
public static boolean ulpEquals(double d1, double d2) Checks that double arguments are within one ULP of each other- Parameters:
d1
-d2
-- Returns:
- true if both numbers are within 1 ULP of each other, false otherwise
-
exactEquals
public static boolean exactEquals(float f1, float f2) Exact float equality check- Parameters:
f1
-f2
-- Returns:
- true if float arguments have the same exact binary value
-
exactEquals
public static boolean exactEquals(double d1, double d2) Exact double equality check- Parameters:
d1
-d2
-- Returns:
- true if float arguments have the same exact binary value
-
isNumeric
Checks that text is a number- Parameters:
text
-- Returns:
- true if the string is a valid base 10 integer or decimal number w/o exponent
-
isNumericExp
Checks that text is a number allowing for exponent- Parameters:
text
-- Returns:
- true if the string is a valid base 10 integer or decimal number, optionally with exponent notation
-