test/java/lang/Math/IeeeRecommendedTests.java
Print this page
*** 175,185 ****
failures += testGetExponentCase(randFloat, i);
}
if (i > FloatConsts.MIN_EXPONENT) {
! float po2minus = FpUtils.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
--- 175,185 ----
failures += testGetExponentCase(randFloat, i);
}
if (i > FloatConsts.MIN_EXPONENT) {
! float po2minus = Math.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
*** 203,213 ****
FloatConsts.MIN_EXPONENT - 1);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testGetExponentCase(FpUtils.nextAfter(top, 0.0f),
FloatConsts.MIN_EXPONENT - 1);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
--- 203,213 ----
FloatConsts.MIN_EXPONENT - 1);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testGetExponentCase(Math.nextAfter(top, 0.0f),
FloatConsts.MIN_EXPONENT - 1);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
*** 282,292 ****
failures += testGetExponentCase(randFloat, i);
}
if (i > DoubleConsts.MIN_EXPONENT) {
! double po2minus = FpUtils.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
--- 282,292 ----
failures += testGetExponentCase(randFloat, i);
}
if (i > DoubleConsts.MIN_EXPONENT) {
! double po2minus = Math.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
*** 310,320 ****
DoubleConsts.MIN_EXPONENT - 1);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testGetExponentCase(FpUtils.nextAfter(top, 0.0),
DoubleConsts.MIN_EXPONENT - 1);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
--- 310,320 ----
DoubleConsts.MIN_EXPONENT - 1);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testGetExponentCase(Math.nextAfter(top, 0.0),
DoubleConsts.MIN_EXPONENT - 1);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
*** 1059,1069 ****
int scaleFactor = manyScalingFactors[j];
if (Math.abs(scaleFactor) >= MAX_SCALE) {
float value = someTestCases[i];
failures+=testScalbCase(value,
scaleFactor,
! FpUtils.copySign( (scaleFactor>0?infinityF:0.0f), value) );
}
}
}
// Test cases that could be done with one floating-point
--- 1059,1069 ----
int scaleFactor = manyScalingFactors[j];
if (Math.abs(scaleFactor) >= MAX_SCALE) {
float value = someTestCases[i];
failures+=testScalbCase(value,
scaleFactor,
! Math.copySign( (scaleFactor>0?infinityF:0.0f), value) );
}
}
}
// Test cases that could be done with one floating-point
*** 1093,1103 ****
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
(FpUtils.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
! FpUtils.copySign(infinityF, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0f;
}
}
--- 1093,1103 ----
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
(FpUtils.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
! Math.copySign(infinityF, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0f;
}
}
*** 1266,1276 ****
int scaleFactor = manyScalingFactors[j];
if (Math.abs(scaleFactor) >= MAX_SCALE) {
double value = someTestCases[i];
failures+=testScalbCase(value,
scaleFactor,
! FpUtils.copySign( (scaleFactor>0?infinityD:0.0), value) );
}
}
}
// Test cases that could be done with one floating-point
--- 1266,1276 ----
int scaleFactor = manyScalingFactors[j];
if (Math.abs(scaleFactor) >= MAX_SCALE) {
double value = someTestCases[i];
failures+=testScalbCase(value,
scaleFactor,
! Math.copySign( (scaleFactor>0?infinityD:0.0), value) );
}
}
}
// Test cases that could be done with one floating-point
*** 1300,1310 ****
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
(FpUtils.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
! FpUtils.copySign(infinityD, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0;
}
}
--- 1300,1310 ----
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
(FpUtils.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
! Math.copySign(infinityD, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0;
}
}
*** 1421,1431 ****
for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
float expected;
// Create power of two
float po2 = powerOfTwoF(i);
! expected = FpUtils.scalb(1.0f, i - (FloatConsts.SIGNIFICAND_WIDTH-1));
failures += testUlpCase(po2, expected);
// Generate some random bit patterns for the significand
for(int j = 0; j < 10; j++) {
--- 1421,1431 ----
for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
float expected;
// Create power of two
float po2 = powerOfTwoF(i);
! expected = Math.scalb(1.0f, i - (FloatConsts.SIGNIFICAND_WIDTH-1));
failures += testUlpCase(po2, expected);
// Generate some random bit patterns for the significand
for(int j = 0; j < 10; j++) {
*** 1441,1451 ****
failures += testUlpCase(randFloat, expected);
}
if (i > FloatConsts.MIN_EXPONENT) {
! float po2minus = FpUtils.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
--- 1441,1451 ----
failures += testUlpCase(randFloat, expected);
}
if (i > FloatConsts.MIN_EXPONENT) {
! float po2minus = Math.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
*** 1468,1478 ****
failures += testUlpCase(top, Float.MIN_VALUE);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testUlpCase(FpUtils.nextAfter(top, 0.0f),
Float.MIN_VALUE);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
--- 1468,1478 ----
failures += testUlpCase(top, Float.MIN_VALUE);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testUlpCase(Math.nextAfter(top, 0.0f),
Float.MIN_VALUE);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
*** 1526,1536 ****
for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
double expected;
// Create power of two
double po2 = powerOfTwoD(i);
! expected = FpUtils.scalb(1.0, i - (DoubleConsts.SIGNIFICAND_WIDTH-1));
failures += testUlpCase(po2, expected);
// Generate some random bit patterns for the significand
for(int j = 0; j < 10; j++) {
--- 1526,1536 ----
for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
double expected;
// Create power of two
double po2 = powerOfTwoD(i);
! expected = Math.scalb(1.0, i - (DoubleConsts.SIGNIFICAND_WIDTH-1));
failures += testUlpCase(po2, expected);
// Generate some random bit patterns for the significand
for(int j = 0; j < 10; j++) {
*** 1546,1556 ****
failures += testUlpCase(randDouble, expected);
}
if (i > DoubleConsts.MIN_EXPONENT) {
! double po2minus = FpUtils.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
--- 1546,1556 ----
failures += testUlpCase(randDouble, expected);
}
if (i > DoubleConsts.MIN_EXPONENT) {
! double po2minus = Math.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
*** 1573,1583 ****
failures += testUlpCase(top, Double.MIN_VALUE);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testUlpCase(FpUtils.nextAfter(top, 0.0f),
Double.MIN_VALUE);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
--- 1573,1583 ----
failures += testUlpCase(top, Double.MIN_VALUE);
// Test largest value in next smaller binade
if (i >= 3) {// (i == 1) would test 0.0;
// (i == 2) would just retest MIN_VALUE
! testUlpCase(Math.nextAfter(top, 0.0f),
Double.MIN_VALUE);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits