Class DoubleUtilities

Object
DoubleUtilities

public class DoubleUtilities extends Object
Utilities for arithmetic operations involving type double.
Author:
Owen Feehan
  • 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 and value2 differ by less than PrecisionConstants.EPSILON.
    • divideByZeroReplace

      public static double divideByZeroReplace(double numerator, double denominator, double replaceWithIfZero)
      Replaces a value with a constant if the denominator is 0.
      Parameters:
      numerator - numerator.
      denominator - denominator.
      replaceWithIfZero - what to replace with if zero.
      Returns:
      numerator divided denominator or replaceWithIfZero (if denominator is zero).