Package org.apache.commons.numbers.core
Class DDMath
- java.lang.Object
-
- org.apache.commons.numbers.core.DDMath
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DDpow(DD x, int n, long[] exp)Compute the numberxraised to the powern.
-
-
-
Method Detail
-
pow
public static DD pow(DD x, int n, long[] exp)
Compute the numberxraised to the powern.The value is returned as fractional
fand integral2^expcomponents.(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 usingMath.pow(x, n)and the exponent is 0. - If
n = 0the 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
fwill be+/-1such 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[])
- If
-
-