Class DoubleUtilities
Object
DoubleUtilities
Utilities for arithmetic operations involving type
double
.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areEqual
(double value1, double value2) Are the two numbers equal, within a tolerance?static double
divideByZeroReplace
(double numerator, double denominator, double replaceWithIfZero) Replaces a value with a constant if thedenominator
is 0.
-
Method Details
-
areEqual
public static boolean areEqual(double value1, double value2) Are the two numbers equal, within a tolerance?The tolerance is 1.000000013351432E-10f.
- Parameters:
value1
- the first value.value2
- the second value.- Returns:
- true iff
value1
andvalue2
differ by less thanPrecisionConstants.EPSILON
.
-
divideByZeroReplace
public static double divideByZeroReplace(double numerator, double denominator, double replaceWithIfZero) Replaces a value with a constant if thedenominator
is 0.- Parameters:
numerator
- numerator.denominator
- denominator.replaceWithIfZero
- what to replace with if zero.- Returns:
- numerator divided denominator or replaceWithIfZero (if denominator is zero).
-