test/java/lang/Math/HypotTests.java
Print this page
*** 88,98 ****
// Verify hypot(x, 0.0) is close to x over the entire exponent
// range.
for(int i = DoubleConsts.MIN_SUB_EXPONENT;
i <= DoubleConsts.MAX_EXPONENT;
i++) {
! double input = FpUtils.scalb(2, i);
failures += testHypotCase(input, 0.0, input);
}
// Test Pythagorean triples
--- 88,98 ----
// Verify hypot(x, 0.0) is close to x over the entire exponent
// range.
for(int i = DoubleConsts.MIN_SUB_EXPONENT;
i <= DoubleConsts.MAX_EXPONENT;
i++) {
! double input = Math.scalb(2, i);
failures += testHypotCase(input, 0.0, input);
}
// Test Pythagorean triples
*** 124,134 ****
*/
java.util.Random rand = new java.util.Random();
for(int i = 0; i < 1000; i++) {
double d = rand.nextDouble();
// Scale d to have an exponent equal to MAX_EXPONENT -15
! d = FpUtils.scalb(d, DoubleConsts.MAX_EXPONENT
-15 - FpUtils.ilogb(d));
for(int j = 0; j <= 13; j += 1) {
failures += testHypotCase(3*d, 4*d, 5*d, 2.5);
d *= 2.0; // increase exponent by 1
}
--- 124,134 ----
*/
java.util.Random rand = new java.util.Random();
for(int i = 0; i < 1000; i++) {
double d = rand.nextDouble();
// Scale d to have an exponent equal to MAX_EXPONENT -15
! d = Math.scalb(d, DoubleConsts.MAX_EXPONENT
-15 - FpUtils.ilogb(d));
for(int j = 0; j <= 13; j += 1) {
failures += testHypotCase(3*d, 4*d, 5*d, 2.5);
d *= 2.0; // increase exponent by 1
}
*** 151,167 ****
double pcNeighborsHypot[] = new double[5];
double pcNeighborsStrictHypot[] = new double[5];
for(int i = -18; i <= 18; i++) {
! double pc = FpUtils.scalb(1.0, i);
pcNeighbors[2] = pc;
pcNeighbors[1] = FpUtils.nextDown(pc);
pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
! pcNeighbors[3] = FpUtils.nextUp(pc);
! pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
for(int j = 0; j < pcNeighbors.length; j++) {
pcNeighborsHypot[j] = Math.hypot(2.0, pcNeighbors[j]);
pcNeighborsStrictHypot[j] = StrictMath.hypot(2.0, pcNeighbors[j]);
}
--- 151,167 ----
double pcNeighborsHypot[] = new double[5];
double pcNeighborsStrictHypot[] = new double[5];
for(int i = -18; i <= 18; i++) {
! double pc = Math.scalb(1.0, i);
pcNeighbors[2] = pc;
pcNeighbors[1] = FpUtils.nextDown(pc);
pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
! pcNeighbors[3] = Math.nextUp(pc);
! pcNeighbors[4] = Math.nextUp(pcNeighbors[3]);
for(int j = 0; j < pcNeighbors.length; j++) {
pcNeighborsHypot[j] = Math.hypot(2.0, pcNeighbors[j]);
pcNeighborsStrictHypot[j] = StrictMath.hypot(2.0, pcNeighbors[j]);
}