Revert "Attempt to circumvent some errors which seem to be platform-dependent."
This reverts commit c771c0080b
.
The attempt failed, the error is still present.
This commit is contained in:
parent
c771c0080b
commit
6571233ed2
|
@ -315,9 +315,6 @@ public class FastMath {
|
|||
/** Mask used to clear the non-sign part of a long. */
|
||||
private static final long MASK_NON_SIGN_LONG = 0x7fffffffffffffffl;
|
||||
|
||||
/** Bits representation of +1.0. */
|
||||
private static final long PLUS_ONE_BITS = 0x3ff0000000000000L;
|
||||
|
||||
/** 2^52 - double numbers this large must be integral (no fraction) or NaN or Infinite */
|
||||
private static final double TWO_POWER_52 = 4503599627370496.0;
|
||||
/** 2^53 - double numbers this large must be even. */
|
||||
|
@ -1471,10 +1468,6 @@ public class FastMath {
|
|||
return x;
|
||||
}
|
||||
|
||||
if (y != y) { // Y is NaN
|
||||
return y;
|
||||
}
|
||||
|
||||
if (x == 0) {
|
||||
long bits = Double.doubleToRawLongBits(x);
|
||||
if ((bits & 0x8000000000000000L) != 0) {
|
||||
|
@ -1492,13 +1485,18 @@ public class FastMath {
|
|||
|
||||
if (y < 0) {
|
||||
return Double.POSITIVE_INFINITY;
|
||||
} else {
|
||||
}
|
||||
if (y > 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
if (x == Double.POSITIVE_INFINITY) {
|
||||
if (y != y) { // y is NaN
|
||||
return y;
|
||||
}
|
||||
if (y < 0.0) {
|
||||
return 0.0;
|
||||
} else {
|
||||
|
@ -1507,17 +1505,21 @@ public class FastMath {
|
|||
}
|
||||
|
||||
if (y == Double.POSITIVE_INFINITY) {
|
||||
long bitsAbsX = MASK_NON_SIGN_LONG & Double.doubleToRawLongBits(x);
|
||||
if (bitsAbsX > PLUS_ONE_BITS) {
|
||||
return Double.POSITIVE_INFINITY;
|
||||
} else if (bitsAbsX < PLUS_ONE_BITS) {
|
||||
return 0.0;
|
||||
} else {
|
||||
if (x * x == 1.0) {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
if (x * x > 1.0) {
|
||||
return Double.POSITIVE_INFINITY;
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == Double.NEGATIVE_INFINITY) {
|
||||
if (y != y) { // y is NaN
|
||||
return y;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
long yi = (long) y;
|
||||
|
|
|
@ -29,6 +29,8 @@ import org.apache.commons.math4.exception.MathArithmeticException;
|
|||
import org.apache.commons.math4.random.MersenneTwister;
|
||||
import org.apache.commons.math4.random.RandomGenerator;
|
||||
import org.apache.commons.math4.random.Well1024a;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.Precision;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
@ -391,8 +393,6 @@ public class FastMathTest {
|
|||
|
||||
Assert.assertTrue("pow(-2.0, 3.5) should be NaN", Double.isNaN(FastMath.pow(-2.0, 3.5)));
|
||||
|
||||
Assert.assertTrue("pow(-0.0, NaN) should be NaN", Double.isNaN(FastMath.pow(-0.0, Double.NaN)));
|
||||
|
||||
// Added tests for a 100% coverage
|
||||
|
||||
Assert.assertTrue("pow(+Inf, NaN) should be NaN", Double.isNaN(FastMath.pow(Double.POSITIVE_INFINITY, Double.NaN)));
|
||||
|
|
Loading…
Reference in New Issue