Class DDMath


  • public final class DDMath
    extends Object
    Computes extended precision floating-point operations.

    This class supplements the arithmetic operations in the DD class providing greater accuracy at the cost of performance.

    Since:
    1.2
    • Method Detail

      • pow

        public static DD pow​(DD x,
                             int n,
                             long[] exp)
        Compute the number x raised to the power n.

        The value is returned as fractional f and integral 2^exp components.

         (x+xx)^n = (f+ff) * 2^exp
         

        The combined fractional part (f, ff) is in the range [0.5, 1).

        Special cases:

        • If (x, xx) is zero the high part of the fractional part is computed using Math.pow(x, n) and the exponent is 0.
        • If n = 0 the fractional part is 0.5 and the exponent is 1.
        • If (x, xx) is an exact power of 2 the fractional part is 0.5 and the exponent is the power of 2 minus 1.
        • If the result high-part is an exact power of 2 and the low-part has an opposite signed non-zero magnitude then the fraction high-part f will be +/-1 such that the double-double number is in the range [0.5, 1).
        • If the argument is not finite then a fractional representation is not possible. In this case the fraction and the scale factor is undefined.

        The computed result is within 1 eps of the exact result where eps is 2-106.

        The performance is approximately 4-fold slower than DD.pow(int, long[]).

        Parameters:
        x - Number.
        n - Power.
        exp - Result power of two scale factor (integral exponent).
        Returns:
        Fraction part.
        See Also:
        DD.frexp(int[])