Package org.apache.commons.numbers.core
Class DDMath
java.lang.Object
org.apache.commons.numbers.core.DDMath
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 Summary
-
Method Details
-
pow
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:
- If
-