java.lang.Object
com.aquima.interactions.expressions.runtime.FloatMath

public final class FloatMath extends Object
Floating point fixing for enhanced precision.
Since:
5.0
Author:
F. vd Meer, E. de Lang
  • Method Details

    • floatFix

      public static double floatFix(double doubleValue)
      Round a number after 15 digits, including the digits before the decimal separator. This will remove most cumulative floating-point errors due to floating-point calculations. The size of floating point error can increase into the 14th digit after more than 6 floating-point operations. For minimal error, it is recommended to use this function after each floating-point calculation. Minimally, it to be call before any compare or modulus operation to have any effect.
      Parameters:
      doubleValue - Value to be rounded
      Returns:
      double Rounded value
    • getFactorFor15DigitShift

      public static double getFactorFor15DigitShift(double doubleValue)
      The method calculates the factor need, for a number to move it's first digit 15 positions before the decimal-point. The maximum factor return is a 15 digit left-shift. This factor equals: Math.pow(10d, 14 - Math.floor(Math.log(Math.abs(value)) / Math.log(10.0))) For performance reasons and to minimize floating point errors, this method is implemented without the use of Math.log and Math.pow.
      Parameters:
      doubleValue - to be shifted double
      Returns:
      double the factor