MATH-489 Fix overflows in acos calculation
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1061609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e90dd494b
commit
81ba9842e5
|
@ -3135,7 +3135,18 @@ public class FastMath {
|
|||
|
||||
// Compute ratio r = y/x
|
||||
double r = y/x;
|
||||
temp = r * 1073741824.0;
|
||||
|
||||
// Did r overflow?
|
||||
if (Double.isInfinite(r)) { // x is effectively zero
|
||||
return Math.PI/2; // so return the appropriate value
|
||||
}
|
||||
|
||||
if (abs(r) < Double.MAX_VALUE/1073741824.0){ // is it safe to split r ?
|
||||
temp = r * 1073741824.0;
|
||||
} else {
|
||||
temp = 0.0;
|
||||
}
|
||||
|
||||
double ra = r + temp - temp;
|
||||
double rb = r - ra;
|
||||
|
||||
|
|
Loading…
Reference in New Issue