test/java/lang/Math/IeeeRecommendedTests.java
Print this page
*** 23,37 ****
/*
* @test
* @bug 4860891 4826732 4780454 4939441 4826652
* @summary Tests for IEEE 754[R] recommended functions and similar methods
* @author Joseph D. Darcy
*/
! import sun.misc.DoubleConsts;
! import sun.misc.FloatConsts;
public class IeeeRecommendedTests {
private IeeeRecommendedTests(){}
static final float NaNf = Float.NaN;
--- 23,40 ----
/*
* @test
* @bug 4860891 4826732 4780454 4939441 4826652
* @summary Tests for IEEE 754[R] recommended functions and similar methods
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.DoubleUtils jdk.testlibrary.FloatUtils
+ * @run main IeeeRecommendedTests
* @author Joseph D. Darcy
*/
! import jdk.testlibrary.DoubleUtils;
! import jdk.testlibrary.FloatUtils;
public class IeeeRecommendedTests {
private IeeeRecommendedTests(){}
static final float NaNf = Float.NaN;
*** 52,73 ****
/**
* Returns a floating-point power of two in the normal range.
*/
static double powerOfTwoD(int n) {
! return Double.longBitsToDouble((((long)n + (long)DoubleConsts.MAX_EXPONENT) <<
! (DoubleConsts.SIGNIFICAND_WIDTH-1))
! & DoubleConsts.EXP_BIT_MASK);
}
/**
* Returns a floating-point power of two in the normal range.
*/
static float powerOfTwoF(int n) {
! return Float.intBitsToFloat(((n + FloatConsts.MAX_EXPONENT) <<
! (FloatConsts.SIGNIFICAND_WIDTH-1))
! & FloatConsts.EXP_BIT_MASK);
}
/* ******************** getExponent tests ****************************** */
/*
--- 55,76 ----
/**
* Returns a floating-point power of two in the normal range.
*/
static double powerOfTwoD(int n) {
! return Double.longBitsToDouble((((long)n + (long)Double.MAX_EXPONENT) <<
! (DoubleUtils.SIGNIFICAND_WIDTH-1))
! & DoubleUtils.EXP_BIT_MASK);
}
/**
* Returns a floating-point power of two in the normal range.
*/
static float powerOfTwoF(int n) {
! return Float.intBitsToFloat(((n + Float.MAX_EXPONENT) <<
! (FloatUtils.SIGNIFICAND_WIDTH-1))
! & FloatUtils.EXP_BIT_MASK);
}
/* ******************** getExponent tests ****************************** */
/*
*** 127,160 ****
+1.0f,
+2.0f,
+16.0f,
+Float.MIN_VALUE,
+Float_MAX_SUBNORMAL,
! +FloatConsts.MIN_NORMAL,
+Float.MAX_VALUE
};
int [] specialResults = {Float.MAX_EXPONENT + 1, // NaN results
Float.MAX_EXPONENT + 1, // Infinite results
Float.MIN_EXPONENT - 1, // Zero results
0,
1,
4,
! FloatConsts.MIN_EXPONENT - 1,
! -FloatConsts.MAX_EXPONENT,
! FloatConsts.MIN_EXPONENT,
! FloatConsts.MAX_EXPONENT
};
// Special value tests
for(int i = 0; i < specialValues.length; i++) {
failures += testGetExponentCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
int result;
// Create power of two
float po2 = powerOfTwoF(i);
--- 130,163 ----
+1.0f,
+2.0f,
+16.0f,
+Float.MIN_VALUE,
+Float_MAX_SUBNORMAL,
! +Float.MIN_NORMAL,
+Float.MAX_VALUE
};
int [] specialResults = {Float.MAX_EXPONENT + 1, // NaN results
Float.MAX_EXPONENT + 1, // Infinite results
Float.MIN_EXPONENT - 1, // Zero results
0,
1,
4,
! Float.MIN_EXPONENT - 1,
! -Float.MAX_EXPONENT,
! Float.MIN_EXPONENT,
! Float.MAX_EXPONENT
};
// Special value tests
for(int i = 0; i < specialValues.length; i++) {
failures += testGetExponentCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! for(int i = Float.MIN_EXPONENT; i <= Float.MAX_EXPONENT; i++) {
int result;
// Create power of two
float po2 = powerOfTwoF(i);
*** 165,183 ****
int randSignif = rand.nextInt();
float randFloat;
randFloat = Float.intBitsToFloat( // Exponent
(Float.floatToIntBits(po2)&
! (~FloatConsts.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! FloatConsts.SIGNIF_BIT_MASK) );
failures += testGetExponentCase(randFloat, i);
}
! if (i > FloatConsts.MIN_EXPONENT) {
float po2minus = Math.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
--- 168,186 ----
int randSignif = rand.nextInt();
float randFloat;
randFloat = Float.intBitsToFloat( // Exponent
(Float.floatToIntBits(po2)&
! (~FloatUtils.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! FloatUtils.SIGNIF_BIT_MASK) );
failures += testGetExponentCase(randFloat, i);
}
! if (i > Float.MIN_EXPONENT) {
float po2minus = Math.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
*** 193,213 ****
* needed.
*/
float top=Float.MIN_VALUE;
for( int i = 1;
! i < FloatConsts.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testGetExponentCase(top,
! 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
int mask = ~((~0)<<(i-1));
--- 196,216 ----
* needed.
*/
float top=Float.MIN_VALUE;
for( int i = 1;
! i < FloatUtils.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testGetExponentCase(top,
! Float.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),
! Float.MIN_EXPONENT - 1);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
int mask = ~((~0)<<(i-1));
*** 215,225 ****
Float.floatToIntBits(top) |
// Significand
(rand.nextInt() & mask ) ) ;
failures += testGetExponentCase(randFloat,
! FloatConsts.MIN_EXPONENT - 1);
}
}
}
return failures;
--- 218,228 ----
Float.floatToIntBits(top) |
// Significand
(rand.nextInt() & mask ) ) ;
failures += testGetExponentCase(randFloat,
! Float.MIN_EXPONENT - 1);
}
}
}
return failures;
*** 234,267 ****
+1.0,
+2.0,
+16.0,
+Double.MIN_VALUE,
+Double_MAX_SUBNORMAL,
! +DoubleConsts.MIN_NORMAL,
+Double.MAX_VALUE
};
int [] specialResults = {Double.MAX_EXPONENT + 1, // NaN results
Double.MAX_EXPONENT + 1, // Infinite results
Double.MIN_EXPONENT - 1, // Zero results
0,
1,
4,
! DoubleConsts.MIN_EXPONENT - 1,
! -DoubleConsts.MAX_EXPONENT,
! DoubleConsts.MIN_EXPONENT,
! DoubleConsts.MAX_EXPONENT
};
// Special value tests
for(int i = 0; i < specialValues.length; i++) {
failures += testGetExponentCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
int result;
// Create power of two
double po2 = powerOfTwoD(i);
--- 237,270 ----
+1.0,
+2.0,
+16.0,
+Double.MIN_VALUE,
+Double_MAX_SUBNORMAL,
! +Double.MIN_NORMAL,
+Double.MAX_VALUE
};
int [] specialResults = {Double.MAX_EXPONENT + 1, // NaN results
Double.MAX_EXPONENT + 1, // Infinite results
Double.MIN_EXPONENT - 1, // Zero results
0,
1,
4,
! Double.MIN_EXPONENT - 1,
! -Double.MAX_EXPONENT,
! Double.MIN_EXPONENT,
! Double.MAX_EXPONENT
};
// Special value tests
for(int i = 0; i < specialValues.length; i++) {
failures += testGetExponentCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) {
int result;
// Create power of two
double po2 = powerOfTwoD(i);
*** 272,290 ****
long randSignif = rand.nextLong();
double randFloat;
randFloat = Double.longBitsToDouble( // Exponent
(Double.doubleToLongBits(po2)&
! (~DoubleConsts.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! DoubleConsts.SIGNIF_BIT_MASK) );
failures += testGetExponentCase(randFloat, i);
}
! if (i > DoubleConsts.MIN_EXPONENT) {
double po2minus = Math.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
--- 275,293 ----
long randSignif = rand.nextLong();
double randFloat;
randFloat = Double.longBitsToDouble( // Exponent
(Double.doubleToLongBits(po2)&
! (~DoubleUtils.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! DoubleUtils.SIGNIF_BIT_MASK) );
failures += testGetExponentCase(randFloat, i);
}
! if (i > Double.MIN_EXPONENT) {
double po2minus = Math.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testGetExponentCase(po2minus, i-1);
}
}
*** 300,320 ****
* needed.
*/
double top=Double.MIN_VALUE;
for( int i = 1;
! i < DoubleConsts.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testGetExponentCase(top,
! 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
long mask = ~((~0L)<<(i-1));
--- 303,323 ----
* needed.
*/
double top=Double.MIN_VALUE;
for( int i = 1;
! i < DoubleUtils.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testGetExponentCase(top,
! Double.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),
! Double.MIN_EXPONENT - 1);
if( i >= 10) {
// create a bit mask with (i-1) 1's in the low order
// bits
long mask = ~((~0L)<<(i-1));
*** 322,332 ****
Double.doubleToLongBits(top) |
// Significand
(rand.nextLong() & mask ) ) ;
failures += testGetExponentCase(randFloat,
! DoubleConsts.MIN_EXPONENT - 1);
}
}
}
return failures;
--- 325,335 ----
Double.doubleToLongBits(top) |
// Significand
(rand.nextLong() & mask ) ) ;
failures += testGetExponentCase(randFloat,
! Double.MIN_EXPONENT - 1);
}
}
}
return failures;
*** 398,416 ****
{Float_MAX_VALUEmm, Float.MAX_VALUE, Float.MAX_VALUE},
{Float_MAX_VALUEmm, infinityF, Float.MAX_VALUE},
{Float_MAX_VALUEmm, Float_MAX_VALUEmm, Float_MAX_VALUEmm},
! {FloatConsts.MIN_NORMAL, infinityF, FloatConsts.MIN_NORMAL+
Float.MIN_VALUE},
! {FloatConsts.MIN_NORMAL, -infinityF, Float_MAX_SUBNORMAL},
! {FloatConsts.MIN_NORMAL, 1.0f, FloatConsts.MIN_NORMAL+
Float.MIN_VALUE},
! {FloatConsts.MIN_NORMAL, -1.0f, Float_MAX_SUBNORMAL},
! {FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
! {Float_MAX_SUBNORMAL, FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
{Float_MAX_SUBNORMAL, Float_MAX_SUBNORMAL, Float_MAX_SUBNORMAL},
{Float_MAX_SUBNORMAL, 0.0f, Float_MAX_SUBNORMALmm},
{Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMAL, Float_MAX_SUBNORMAL},
{Float_MAX_SUBNORMALmm, 0.0f, Float_MAX_SUBNORMALmm-Float.MIN_VALUE},
--- 401,419 ----
{Float_MAX_VALUEmm, Float.MAX_VALUE, Float.MAX_VALUE},
{Float_MAX_VALUEmm, infinityF, Float.MAX_VALUE},
{Float_MAX_VALUEmm, Float_MAX_VALUEmm, Float_MAX_VALUEmm},
! {Float.MIN_NORMAL, infinityF, Float.MIN_NORMAL+
Float.MIN_VALUE},
! {Float.MIN_NORMAL, -infinityF, Float_MAX_SUBNORMAL},
! {Float.MIN_NORMAL, 1.0f, Float.MIN_NORMAL+
Float.MIN_VALUE},
! {Float.MIN_NORMAL, -1.0f, Float_MAX_SUBNORMAL},
! {Float.MIN_NORMAL, Float.MIN_NORMAL, Float.MIN_NORMAL},
! {Float_MAX_SUBNORMAL, Float.MIN_NORMAL, Float.MIN_NORMAL},
{Float_MAX_SUBNORMAL, Float_MAX_SUBNORMAL, Float_MAX_SUBNORMAL},
{Float_MAX_SUBNORMAL, 0.0f, Float_MAX_SUBNORMALmm},
{Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMAL, Float_MAX_SUBNORMAL},
{Float_MAX_SUBNORMALmm, 0.0f, Float_MAX_SUBNORMALmm-Float.MIN_VALUE},
*** 470,488 ****
{Double_MAX_VALUEmm, Double.MAX_VALUE, Double.MAX_VALUE},
{Double_MAX_VALUEmm, infinityD, Double.MAX_VALUE},
{Double_MAX_VALUEmm, Double_MAX_VALUEmm, Double_MAX_VALUEmm},
! {DoubleConsts.MIN_NORMAL, infinityD, DoubleConsts.MIN_NORMAL+
Double.MIN_VALUE},
! {DoubleConsts.MIN_NORMAL, -infinityD, Double_MAX_SUBNORMAL},
! {DoubleConsts.MIN_NORMAL, 1.0f, DoubleConsts.MIN_NORMAL+
Double.MIN_VALUE},
! {DoubleConsts.MIN_NORMAL, -1.0f, Double_MAX_SUBNORMAL},
! {DoubleConsts.MIN_NORMAL, DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
! {Double_MAX_SUBNORMAL, DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
{Double_MAX_SUBNORMAL, Double_MAX_SUBNORMAL, Double_MAX_SUBNORMAL},
{Double_MAX_SUBNORMAL, 0.0d, Double_MAX_SUBNORMALmm},
{Double_MAX_SUBNORMALmm, Double_MAX_SUBNORMAL, Double_MAX_SUBNORMAL},
{Double_MAX_SUBNORMALmm, 0.0d, Double_MAX_SUBNORMALmm-Double.MIN_VALUE},
--- 473,491 ----
{Double_MAX_VALUEmm, Double.MAX_VALUE, Double.MAX_VALUE},
{Double_MAX_VALUEmm, infinityD, Double.MAX_VALUE},
{Double_MAX_VALUEmm, Double_MAX_VALUEmm, Double_MAX_VALUEmm},
! {Double.MIN_NORMAL, infinityD, Double.MIN_NORMAL+
Double.MIN_VALUE},
! {Double.MIN_NORMAL, -infinityD, Double_MAX_SUBNORMAL},
! {Double.MIN_NORMAL, 1.0f, Double.MIN_NORMAL+
Double.MIN_VALUE},
! {Double.MIN_NORMAL, -1.0f, Double_MAX_SUBNORMAL},
! {Double.MIN_NORMAL, Double.MIN_NORMAL, Double.MIN_NORMAL},
! {Double_MAX_SUBNORMAL, Double.MIN_NORMAL, Double.MIN_NORMAL},
{Double_MAX_SUBNORMAL, Double_MAX_SUBNORMAL, Double_MAX_SUBNORMAL},
{Double_MAX_SUBNORMAL, 0.0d, Double_MAX_SUBNORMALmm},
{Double_MAX_SUBNORMALmm, Double_MAX_SUBNORMAL, Double_MAX_SUBNORMAL},
{Double_MAX_SUBNORMALmm, 0.0d, Double_MAX_SUBNORMALmm-Double.MIN_VALUE},
*** 527,545 ****
*/
float testCases [][] = {
{NaNf, NaNf},
{-infinityF, -Float.MAX_VALUE},
{-Float.MAX_VALUE, -Float_MAX_VALUEmm},
! {-FloatConsts.MIN_NORMAL, -Float_MAX_SUBNORMAL},
{-Float_MAX_SUBNORMAL, -Float_MAX_SUBNORMALmm},
{-Float.MIN_VALUE, -0.0f},
{-0.0f, Float.MIN_VALUE},
{+0.0f, Float.MIN_VALUE},
{Float.MIN_VALUE, Float.MIN_VALUE*2},
{Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMAL},
! {Float_MAX_SUBNORMAL, FloatConsts.MIN_NORMAL},
! {FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL+Float.MIN_VALUE},
{Float_MAX_VALUEmm, Float.MAX_VALUE},
{Float.MAX_VALUE, infinityF},
{infinityF, infinityF}
};
--- 530,548 ----
*/
float testCases [][] = {
{NaNf, NaNf},
{-infinityF, -Float.MAX_VALUE},
{-Float.MAX_VALUE, -Float_MAX_VALUEmm},
! {-Float.MIN_NORMAL, -Float_MAX_SUBNORMAL},
{-Float_MAX_SUBNORMAL, -Float_MAX_SUBNORMALmm},
{-Float.MIN_VALUE, -0.0f},
{-0.0f, Float.MIN_VALUE},
{+0.0f, Float.MIN_VALUE},
{Float.MIN_VALUE, Float.MIN_VALUE*2},
{Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMAL},
! {Float_MAX_SUBNORMAL, Float.MIN_NORMAL},
! {Float.MIN_NORMAL, Float.MIN_NORMAL+Float.MIN_VALUE},
{Float_MAX_VALUEmm, Float.MAX_VALUE},
{Float.MAX_VALUE, infinityF},
{infinityF, infinityF}
};
*** 565,583 ****
*/
double testCases [][] = {
{NaNd, NaNd},
{-infinityD, -Double.MAX_VALUE},
{-Double.MAX_VALUE, -Double_MAX_VALUEmm},
! {-DoubleConsts.MIN_NORMAL, -Double_MAX_SUBNORMAL},
{-Double_MAX_SUBNORMAL, -Double_MAX_SUBNORMALmm},
{-Double.MIN_VALUE, -0.0d},
{-0.0d, Double.MIN_VALUE},
{+0.0d, Double.MIN_VALUE},
{Double.MIN_VALUE, Double.MIN_VALUE*2},
{Double_MAX_SUBNORMALmm, Double_MAX_SUBNORMAL},
! {Double_MAX_SUBNORMAL, DoubleConsts.MIN_NORMAL},
! {DoubleConsts.MIN_NORMAL, DoubleConsts.MIN_NORMAL+Double.MIN_VALUE},
{Double_MAX_VALUEmm, Double.MAX_VALUE},
{Double.MAX_VALUE, infinityD},
{infinityD, infinityD}
};
--- 568,586 ----
*/
double testCases [][] = {
{NaNd, NaNd},
{-infinityD, -Double.MAX_VALUE},
{-Double.MAX_VALUE, -Double_MAX_VALUEmm},
! {-Double.MIN_NORMAL, -Double_MAX_SUBNORMAL},
{-Double_MAX_SUBNORMAL, -Double_MAX_SUBNORMALmm},
{-Double.MIN_VALUE, -0.0d},
{-0.0d, Double.MIN_VALUE},
{+0.0d, Double.MIN_VALUE},
{Double.MIN_VALUE, Double.MIN_VALUE*2},
{Double_MAX_SUBNORMALmm, Double_MAX_SUBNORMAL},
! {Double_MAX_SUBNORMAL, Double.MIN_NORMAL},
! {Double.MIN_NORMAL, Double.MIN_NORMAL+Double.MIN_VALUE},
{Double_MAX_VALUEmm, Double.MAX_VALUE},
{Double.MAX_VALUE, infinityD},
{infinityD, infinityD}
};
*** 605,624 ****
float testCases [][] = {
{NaNf, NaNf},
{-infinityF, -infinityF},
{-Float.MAX_VALUE, -infinityF},
{-Float_MAX_VALUEmm, -Float.MAX_VALUE},
! {-Float_MAX_SUBNORMAL, -FloatConsts.MIN_NORMAL},
{-Float_MAX_SUBNORMALmm, -Float_MAX_SUBNORMAL},
{-0.0f, -Float.MIN_VALUE},
{+0.0f, -Float.MIN_VALUE},
{Float.MIN_VALUE, 0.0f},
{Float.MIN_VALUE*2, Float.MIN_VALUE},
{Float_MAX_SUBNORMAL, Float_MAX_SUBNORMALmm},
! {FloatConsts.MIN_NORMAL, Float_MAX_SUBNORMAL},
! {FloatConsts.MIN_NORMAL+
! Float.MIN_VALUE, FloatConsts.MIN_NORMAL},
{Float.MAX_VALUE, Float_MAX_VALUEmm},
{infinityF, Float.MAX_VALUE},
};
for(int i = 0; i < testCases.length; i++) {
--- 608,627 ----
float testCases [][] = {
{NaNf, NaNf},
{-infinityF, -infinityF},
{-Float.MAX_VALUE, -infinityF},
{-Float_MAX_VALUEmm, -Float.MAX_VALUE},
! {-Float_MAX_SUBNORMAL, -Float.MIN_NORMAL},
{-Float_MAX_SUBNORMALmm, -Float_MAX_SUBNORMAL},
{-0.0f, -Float.MIN_VALUE},
{+0.0f, -Float.MIN_VALUE},
{Float.MIN_VALUE, 0.0f},
{Float.MIN_VALUE*2, Float.MIN_VALUE},
{Float_MAX_SUBNORMAL, Float_MAX_SUBNORMALmm},
! {Float.MIN_NORMAL, Float_MAX_SUBNORMAL},
! {Float.MIN_NORMAL+
! Float.MIN_VALUE, Float.MIN_NORMAL},
{Float.MAX_VALUE, Float_MAX_VALUEmm},
{infinityF, Float.MAX_VALUE},
};
for(int i = 0; i < testCases.length; i++) {
*** 644,663 ****
double testCases [][] = {
{NaNd, NaNd},
{-infinityD, -infinityD},
{-Double.MAX_VALUE, -infinityD},
{-Double_MAX_VALUEmm, -Double.MAX_VALUE},
! {-Double_MAX_SUBNORMAL, -DoubleConsts.MIN_NORMAL},
{-Double_MAX_SUBNORMALmm, -Double_MAX_SUBNORMAL},
{-0.0d, -Double.MIN_VALUE},
{+0.0d, -Double.MIN_VALUE},
{Double.MIN_VALUE, 0.0d},
{Double.MIN_VALUE*2, Double.MIN_VALUE},
{Double_MAX_SUBNORMAL, Double_MAX_SUBNORMALmm},
! {DoubleConsts.MIN_NORMAL, Double_MAX_SUBNORMAL},
! {DoubleConsts.MIN_NORMAL+
! Double.MIN_VALUE, DoubleConsts.MIN_NORMAL},
{Double.MAX_VALUE, Double_MAX_VALUEmm},
{infinityD, Double.MAX_VALUE},
};
for(int i = 0; i < testCases.length; i++) {
--- 647,666 ----
double testCases [][] = {
{NaNd, NaNd},
{-infinityD, -infinityD},
{-Double.MAX_VALUE, -infinityD},
{-Double_MAX_VALUEmm, -Double.MAX_VALUE},
! {-Double_MAX_SUBNORMAL, -Double.MIN_NORMAL},
{-Double_MAX_SUBNORMALmm, -Double_MAX_SUBNORMAL},
{-0.0d, -Double.MIN_VALUE},
{+0.0d, -Double.MIN_VALUE},
{Double.MIN_VALUE, 0.0d},
{Double.MIN_VALUE*2, Double.MIN_VALUE},
{Double_MAX_SUBNORMAL, Double_MAX_SUBNORMALmm},
! {Double.MIN_NORMAL, Double_MAX_SUBNORMAL},
! {Double.MIN_NORMAL+
! Double.MIN_VALUE, Double.MIN_NORMAL},
{Double.MAX_VALUE, Double_MAX_VALUEmm},
{infinityD, Double.MAX_VALUE},
};
for(int i = 0; i < testCases.length; i++) {
*** 687,706 ****
-infinityF,
infinityF,
-Float.MAX_VALUE,
-3.0f,
-1.0f,
! -FloatConsts.MIN_NORMAL,
-Float_MAX_SUBNORMALmm,
-Float_MAX_SUBNORMAL,
-Float.MIN_VALUE,
-0.0f,
+0.0f,
Float.MIN_VALUE,
Float_MAX_SUBNORMALmm,
Float_MAX_SUBNORMAL,
! FloatConsts.MIN_NORMAL,
1.0f,
3.0f,
Float_MAX_VALUEmm,
Float.MAX_VALUE
};
--- 690,709 ----
-infinityF,
infinityF,
-Float.MAX_VALUE,
-3.0f,
-1.0f,
! -Float.MIN_NORMAL,
-Float_MAX_SUBNORMALmm,
-Float_MAX_SUBNORMAL,
-Float.MIN_VALUE,
-0.0f,
+0.0f,
Float.MIN_VALUE,
Float_MAX_SUBNORMALmm,
Float_MAX_SUBNORMAL,
! Float.MIN_NORMAL,
1.0f,
3.0f,
Float_MAX_VALUEmm,
Float.MAX_VALUE
};
*** 737,756 ****
-infinityD,
infinityD,
-Double.MAX_VALUE,
-3.0d,
-1.0d,
! -DoubleConsts.MIN_NORMAL,
-Double_MAX_SUBNORMALmm,
-Double_MAX_SUBNORMAL,
-Double.MIN_VALUE,
-0.0d,
+0.0d,
Double.MIN_VALUE,
Double_MAX_SUBNORMALmm,
Double_MAX_SUBNORMAL,
! DoubleConsts.MIN_NORMAL,
1.0d,
3.0d,
Double_MAX_VALUEmm,
Double.MAX_VALUE
};
--- 740,759 ----
-infinityD,
infinityD,
-Double.MAX_VALUE,
-3.0d,
-1.0d,
! -Double.MIN_NORMAL,
-Double_MAX_SUBNORMALmm,
-Double_MAX_SUBNORMAL,
-Double.MIN_VALUE,
-0.0d,
+0.0d,
Double.MIN_VALUE,
Double_MAX_SUBNORMALmm,
Double_MAX_SUBNORMAL,
! Double.MIN_NORMAL,
1.0d,
3.0d,
Double_MAX_VALUEmm,
Double.MAX_VALUE
};
*** 788,809 ****
float testCases [][] = {
{+0.0f,
Float.MIN_VALUE,
Float_MAX_SUBNORMALmm,
Float_MAX_SUBNORMAL,
! FloatConsts.MIN_NORMAL,
1.0f,
3.0f,
Float_MAX_VALUEmm,
Float.MAX_VALUE,
infinityF,
},
{-infinityF,
-Float.MAX_VALUE,
-3.0f,
-1.0f,
! -FloatConsts.MIN_NORMAL,
-Float_MAX_SUBNORMALmm,
-Float_MAX_SUBNORMAL,
-Float.MIN_VALUE,
-0.0f}
};
--- 791,812 ----
float testCases [][] = {
{+0.0f,
Float.MIN_VALUE,
Float_MAX_SUBNORMALmm,
Float_MAX_SUBNORMAL,
! Float.MIN_NORMAL,
1.0f,
3.0f,
Float_MAX_VALUEmm,
Float.MAX_VALUE,
infinityF,
},
{-infinityF,
-Float.MAX_VALUE,
-3.0f,
-1.0f,
! -Float.MIN_NORMAL,
-Float_MAX_SUBNORMALmm,
-Float_MAX_SUBNORMAL,
-Float.MIN_VALUE,
-0.0f}
};
*** 862,883 ****
double testCases [][] = {
{+0.0d,
Double.MIN_VALUE,
Double_MAX_SUBNORMALmm,
Double_MAX_SUBNORMAL,
! DoubleConsts.MIN_NORMAL,
1.0d,
3.0d,
Double_MAX_VALUEmm,
Double.MAX_VALUE,
infinityD,
},
{-infinityD,
-Double.MAX_VALUE,
-3.0d,
-1.0d,
! -DoubleConsts.MIN_NORMAL,
-Double_MAX_SUBNORMALmm,
-Double_MAX_SUBNORMAL,
-Double.MIN_VALUE,
-0.0d}
};
--- 865,886 ----
double testCases [][] = {
{+0.0d,
Double.MIN_VALUE,
Double_MAX_SUBNORMALmm,
Double_MAX_SUBNORMAL,
! Double.MIN_NORMAL,
1.0d,
3.0d,
Double_MAX_VALUEmm,
Double.MAX_VALUE,
infinityD,
},
{-infinityD,
-Double.MAX_VALUE,
-3.0d,
-1.0d,
! -Double.MIN_NORMAL,
-Double_MAX_SUBNORMALmm,
-Double_MAX_SUBNORMAL,
-Double.MIN_VALUE,
-0.0d}
};
*** 962,973 ****
return failures;
}
public static int testFloatScalb() {
int failures=0;
! int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
! FloatConsts.SIGNIFICAND_WIDTH + 1;
// Arguments x, where scalb(x,n) is x for any n.
float [] identityTestCases = {NaNf,
-0.0f,
--- 965,976 ----
return failures;
}
public static int testFloatScalb() {
int failures=0;
! int MAX_SCALE = Float.MAX_EXPONENT + -Float.MIN_EXPONENT +
! FloatUtils.SIGNIFICAND_WIDTH + 1;
// Arguments x, where scalb(x,n) is x for any n.
float [] identityTestCases = {NaNf,
-0.0f,
*** 986,1047 ****
float [] someTestCases = {
Float.MIN_VALUE,
3.0f*Float.MIN_VALUE,
Float_MAX_SUBNORMALmm,
Float_MAX_SUBNORMAL,
! FloatConsts.MIN_NORMAL,
1.0f,
2.0f,
3.0f,
(float)Math.PI,
Float_MAX_VALUEmm,
Float.MAX_VALUE
};
int [] oneMultiplyScalingFactors = {
! FloatConsts.MIN_EXPONENT,
! FloatConsts.MIN_EXPONENT+1,
-3,
-2,
-1,
0,
1,
2,
3,
! FloatConsts.MAX_EXPONENT-1,
! FloatConsts.MAX_EXPONENT
};
int [] manyScalingFactors = {
Integer.MIN_VALUE,
Integer.MIN_VALUE+1,
-MAX_SCALE -1,
-MAX_SCALE,
-MAX_SCALE+1,
! 2*FloatConsts.MIN_EXPONENT-1, // -253
! 2*FloatConsts.MIN_EXPONENT, // -252
! 2*FloatConsts.MIN_EXPONENT+1, // -251
!
! FloatConsts.MIN_EXPONENT - FloatConsts.SIGNIFICAND_WIDTH,
! FloatConsts.MIN_SUB_EXPONENT,
! -FloatConsts.MAX_EXPONENT, // -127
! FloatConsts.MIN_EXPONENT, // -126
-2,
-1,
0,
1,
2,
! FloatConsts.MAX_EXPONENT-1, // 126
! FloatConsts.MAX_EXPONENT, // 127
! FloatConsts.MAX_EXPONENT+1, // 128
!
! 2*FloatConsts.MAX_EXPONENT-1, // 253
! 2*FloatConsts.MAX_EXPONENT, // 254
! 2*FloatConsts.MAX_EXPONENT+1, // 255
MAX_SCALE-1,
MAX_SCALE,
MAX_SCALE+1,
Integer.MAX_VALUE-1,
--- 989,1050 ----
float [] someTestCases = {
Float.MIN_VALUE,
3.0f*Float.MIN_VALUE,
Float_MAX_SUBNORMALmm,
Float_MAX_SUBNORMAL,
! Float.MIN_NORMAL,
1.0f,
2.0f,
3.0f,
(float)Math.PI,
Float_MAX_VALUEmm,
Float.MAX_VALUE
};
int [] oneMultiplyScalingFactors = {
! Float.MIN_EXPONENT,
! Float.MIN_EXPONENT+1,
-3,
-2,
-1,
0,
1,
2,
3,
! Float.MAX_EXPONENT-1,
! Float.MAX_EXPONENT
};
int [] manyScalingFactors = {
Integer.MIN_VALUE,
Integer.MIN_VALUE+1,
-MAX_SCALE -1,
-MAX_SCALE,
-MAX_SCALE+1,
! 2*Float.MIN_EXPONENT-1, // -253
! 2*Float.MIN_EXPONENT, // -252
! 2*Float.MIN_EXPONENT+1, // -251
!
! Float.MIN_EXPONENT - FloatUtils.SIGNIFICAND_WIDTH,
! FloatUtils.MIN_SUB_EXPONENT,
! -Float.MAX_EXPONENT, // -127
! Float.MIN_EXPONENT, // -126
-2,
-1,
0,
1,
2,
! Float.MAX_EXPONENT-1, // 126
! Float.MAX_EXPONENT, // 127
! Float.MAX_EXPONENT+1, // 128
!
! 2*Float.MAX_EXPONENT-1, // 253
! 2*Float.MAX_EXPONENT, // 254
! 2*Float.MAX_EXPONENT+1, // 255
MAX_SCALE-1,
MAX_SCALE,
MAX_SCALE+1,
Integer.MAX_VALUE-1,
*** 1084,1107 ****
}
}
// Create 2^MAX_EXPONENT
float twoToTheMaxExp = 1.0f; // 2^0
! for(int i = 0; i < FloatConsts.MAX_EXPONENT; i++)
twoToTheMaxExp *=2.0f;
// Scale-up subnormal values until they all overflow
for(int i=0; i < subnormalTestCases.length; i++) {
float scale = 1.0f; // 2^j
float value = subnormalTestCases[i];
! for(int j=FloatConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
! (Tests.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
Math.copySign(infinityF, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0f;
}
--- 1087,1110 ----
}
}
// Create 2^MAX_EXPONENT
float twoToTheMaxExp = 1.0f; // 2^0
! for(int i = 0; i < Float.MAX_EXPONENT; i++)
twoToTheMaxExp *=2.0f;
// Scale-up subnormal values until they all overflow
for(int i=0; i < subnormalTestCases.length; i++) {
float scale = 1.0f; // 2^j
float value = subnormalTestCases[i];
! for(int j=Float.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
! (Tests.ilogb(value) +j > Float.MAX_EXPONENT ) ?
Math.copySign(infinityF, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0f;
}
*** 1170,1181 ****
return failures;
}
public static int testDoubleScalb() {
int failures=0;
! int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
! DoubleConsts.SIGNIFICAND_WIDTH + 1;
// Arguments x, where scalb(x,n) is x for any n.
double [] identityTestCases = {NaNd,
-0.0,
--- 1173,1184 ----
return failures;
}
public static int testDoubleScalb() {
int failures=0;
! int MAX_SCALE = Double.MAX_EXPONENT + -Double.MIN_EXPONENT +
! DoubleUtils.SIGNIFICAND_WIDTH + 1;
// Arguments x, where scalb(x,n) is x for any n.
double [] identityTestCases = {NaNd,
-0.0,
*** 1193,1255 ****
double [] someTestCases = {
Double.MIN_VALUE,
3.0d*Double.MIN_VALUE,
Double_MAX_SUBNORMALmm,
Double_MAX_SUBNORMAL,
! DoubleConsts.MIN_NORMAL,
1.0d,
2.0d,
3.0d,
Math.PI,
Double_MAX_VALUEmm,
Double.MAX_VALUE
};
int [] oneMultiplyScalingFactors = {
! DoubleConsts.MIN_EXPONENT,
! DoubleConsts.MIN_EXPONENT+1,
-3,
-2,
-1,
0,
1,
2,
3,
! DoubleConsts.MAX_EXPONENT-1,
! DoubleConsts.MAX_EXPONENT
};
int [] manyScalingFactors = {
Integer.MIN_VALUE,
Integer.MIN_VALUE+1,
-MAX_SCALE -1,
-MAX_SCALE,
-MAX_SCALE+1,
! 2*DoubleConsts.MIN_EXPONENT-1, // -2045
! 2*DoubleConsts.MIN_EXPONENT, // -2044
! 2*DoubleConsts.MIN_EXPONENT+1, // -2043
!
! DoubleConsts.MIN_EXPONENT, // -1022
! DoubleConsts.MIN_EXPONENT - DoubleConsts.SIGNIFICAND_WIDTH,
! DoubleConsts.MIN_SUB_EXPONENT,
! -DoubleConsts.MAX_EXPONENT, // -1023
! DoubleConsts.MIN_EXPONENT, // -1022
-2,
-1,
0,
1,
2,
! DoubleConsts.MAX_EXPONENT-1, // 1022
! DoubleConsts.MAX_EXPONENT, // 1023
! DoubleConsts.MAX_EXPONENT+1, // 1024
!
! 2*DoubleConsts.MAX_EXPONENT-1, // 2045
! 2*DoubleConsts.MAX_EXPONENT, // 2046
! 2*DoubleConsts.MAX_EXPONENT+1, // 2047
MAX_SCALE-1,
MAX_SCALE,
MAX_SCALE+1,
Integer.MAX_VALUE-1,
--- 1196,1258 ----
double [] someTestCases = {
Double.MIN_VALUE,
3.0d*Double.MIN_VALUE,
Double_MAX_SUBNORMALmm,
Double_MAX_SUBNORMAL,
! Double.MIN_NORMAL,
1.0d,
2.0d,
3.0d,
Math.PI,
Double_MAX_VALUEmm,
Double.MAX_VALUE
};
int [] oneMultiplyScalingFactors = {
! Double.MIN_EXPONENT,
! Double.MIN_EXPONENT+1,
-3,
-2,
-1,
0,
1,
2,
3,
! Double.MAX_EXPONENT-1,
! Double.MAX_EXPONENT
};
int [] manyScalingFactors = {
Integer.MIN_VALUE,
Integer.MIN_VALUE+1,
-MAX_SCALE -1,
-MAX_SCALE,
-MAX_SCALE+1,
! 2*Double.MIN_EXPONENT-1, // -2045
! 2*Double.MIN_EXPONENT, // -2044
! 2*Double.MIN_EXPONENT+1, // -2043
!
! Double.MIN_EXPONENT, // -1022
! Double.MIN_EXPONENT - DoubleUtils.SIGNIFICAND_WIDTH,
! DoubleUtils.MIN_SUB_EXPONENT,
! -Double.MAX_EXPONENT, // -1023
! Double.MIN_EXPONENT, // -1022
-2,
-1,
0,
1,
2,
! Double.MAX_EXPONENT-1, // 1022
! Double.MAX_EXPONENT, // 1023
! Double.MAX_EXPONENT+1, // 1024
!
! 2*Double.MAX_EXPONENT-1, // 2045
! 2*Double.MAX_EXPONENT, // 2046
! 2*Double.MAX_EXPONENT+1, // 2047
MAX_SCALE-1,
MAX_SCALE,
MAX_SCALE+1,
Integer.MAX_VALUE-1,
*** 1292,1315 ****
}
}
// Create 2^MAX_EXPONENT
double twoToTheMaxExp = 1.0; // 2^0
! for(int i = 0; i < DoubleConsts.MAX_EXPONENT; i++)
twoToTheMaxExp *=2.0;
// Scale-up subnormal values until they all overflow
for(int i=0; i < subnormalTestCases.length; i++) {
double scale = 1.0; // 2^j
double value = subnormalTestCases[i];
! for(int j=DoubleConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
! (Tests.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
Math.copySign(infinityD, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0;
}
--- 1295,1318 ----
}
}
// Create 2^MAX_EXPONENT
double twoToTheMaxExp = 1.0; // 2^0
! for(int i = 0; i < Double.MAX_EXPONENT; i++)
twoToTheMaxExp *=2.0;
// Scale-up subnormal values until they all overflow
for(int i=0; i < subnormalTestCases.length; i++) {
double scale = 1.0; // 2^j
double value = subnormalTestCases[i];
! for(int j=Double.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
int scaleFactor = j;
failures+=testScalbCase(value,
scaleFactor,
! (Tests.ilogb(value) +j > Double.MAX_EXPONENT ) ?
Math.copySign(infinityD, value) : // overflow
// calculate right answer
twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
scale*=2.0;
}
*** 1343,1353 ****
// multiplies, the value would round twice if the multiplies
// were done in the wrong order.
double value = 0x1.000000000000bP-1;
expected = 0x0.2000000000001P-1022;
! for(int i = 0; i < DoubleConsts.MAX_EXPONENT+2; i++) {
failures+=testScalbCase(value,
-1024-i,
expected);
value *=2.0;
}
--- 1346,1356 ----
// multiplies, the value would round twice if the multiplies
// were done in the wrong order.
double value = 0x1.000000000000bP-1;
expected = 0x0.2000000000001P-1022;
! for(int i = 0; i < Double.MAX_EXPONENT+2; i++) {
failures+=testScalbCase(value,
-1024-i,
expected);
value *=2.0;
}
*** 1399,1409 ****
+1.0f,
+2.0f,
+16.0f,
+Float.MIN_VALUE,
+Float_MAX_SUBNORMAL,
! +FloatConsts.MIN_NORMAL,
+Float.MAX_VALUE
};
float [] specialResults = {NaNf,
Float.POSITIVE_INFINITY,
--- 1402,1412 ----
+1.0f,
+2.0f,
+16.0f,
+Float.MIN_VALUE,
+Float_MAX_SUBNORMAL,
! +Float.MIN_NORMAL,
+Float.MAX_VALUE
};
float [] specialResults = {NaNf,
Float.POSITIVE_INFINITY,
*** 1422,1456 ****
failures += testUlpCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! 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++) {
int randSignif = rand.nextInt();
float randFloat;
randFloat = Float.intBitsToFloat( // Exponent
(Float.floatToIntBits(po2)&
! (~FloatConsts.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! FloatConsts.SIGNIF_BIT_MASK) );
failures += testUlpCase(randFloat, expected);
}
! if (i > FloatConsts.MIN_EXPONENT) {
float po2minus = Math.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
--- 1425,1459 ----
failures += testUlpCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! for(int i = Float.MIN_EXPONENT; i <= Float.MAX_EXPONENT; i++) {
float expected;
// Create power of two
float po2 = powerOfTwoF(i);
! expected = Math.scalb(1.0f, i - (FloatUtils.SIGNIFICAND_WIDTH-1));
failures += testUlpCase(po2, expected);
// Generate some random bit patterns for the significand
for(int j = 0; j < 10; j++) {
int randSignif = rand.nextInt();
float randFloat;
randFloat = Float.intBitsToFloat( // Exponent
(Float.floatToIntBits(po2)&
! (~FloatUtils.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! FloatUtils.SIGNIF_BIT_MASK) );
failures += testUlpCase(randFloat, expected);
}
! if (i > Float.MIN_EXPONENT) {
float po2minus = Math.nextAfter(po2,
Float.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
*** 1466,1476 ****
* needed.
*/
float top=Float.MIN_VALUE;
for( int i = 1;
! i < FloatConsts.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testUlpCase(top, Float.MIN_VALUE);
// Test largest value in next smaller binade
--- 1469,1479 ----
* needed.
*/
float top=Float.MIN_VALUE;
for( int i = 1;
! i < FloatUtils.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testUlpCase(top, Float.MIN_VALUE);
// Test largest value in next smaller binade
*** 1504,1514 ****
+1.0d,
+2.0d,
+16.0d,
+Double.MIN_VALUE,
+Double_MAX_SUBNORMAL,
! +DoubleConsts.MIN_NORMAL,
+Double.MAX_VALUE
};
double [] specialResults = {NaNf,
Double.POSITIVE_INFINITY,
--- 1507,1517 ----
+1.0d,
+2.0d,
+16.0d,
+Double.MIN_VALUE,
+Double_MAX_SUBNORMAL,
! +Double.MIN_NORMAL,
+Double.MAX_VALUE
};
double [] specialResults = {NaNf,
Double.POSITIVE_INFINITY,
*** 1527,1561 ****
failures += testUlpCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! 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++) {
long randSignif = rand.nextLong();
double randDouble;
randDouble = Double.longBitsToDouble( // Exponent
(Double.doubleToLongBits(po2)&
! (~DoubleConsts.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! DoubleConsts.SIGNIF_BIT_MASK) );
failures += testUlpCase(randDouble, expected);
}
! if (i > DoubleConsts.MIN_EXPONENT) {
double po2minus = Math.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
--- 1530,1564 ----
failures += testUlpCase(specialValues[i], specialResults[i]);
}
// Normal exponent tests
! for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) {
double expected;
// Create power of two
double po2 = powerOfTwoD(i);
! expected = Math.scalb(1.0, i - (DoubleUtils.SIGNIFICAND_WIDTH-1));
failures += testUlpCase(po2, expected);
// Generate some random bit patterns for the significand
for(int j = 0; j < 10; j++) {
long randSignif = rand.nextLong();
double randDouble;
randDouble = Double.longBitsToDouble( // Exponent
(Double.doubleToLongBits(po2)&
! (~DoubleUtils.SIGNIF_BIT_MASK)) |
// Significand
(randSignif &
! DoubleUtils.SIGNIF_BIT_MASK) );
failures += testUlpCase(randDouble, expected);
}
! if (i > Double.MIN_EXPONENT) {
double po2minus = Math.nextAfter(po2,
Double.NEGATIVE_INFINITY);
failures += testUlpCase(po2minus, expected/2.0f);
}
}
*** 1571,1581 ****
* needed.
*/
double top=Double.MIN_VALUE;
for( int i = 1;
! i < DoubleConsts.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testUlpCase(top, Double.MIN_VALUE);
// Test largest value in next smaller binade
--- 1574,1584 ----
* needed.
*/
double top=Double.MIN_VALUE;
for( int i = 1;
! i < DoubleUtils.SIGNIFICAND_WIDTH;
i++, top *= 2.0f) {
failures += testUlpCase(top, Double.MIN_VALUE);
// Test largest value in next smaller binade
*** 1605,1625 ****
int failures = 0;
float testCases [][] = {
{NaNf, NaNf},
{-infinityF, -1.0f},
{-Float.MAX_VALUE, -1.0f},
! {-FloatConsts.MIN_NORMAL, -1.0f},
{-1.0f, -1.0f},
{-2.0f, -1.0f},
{-Float_MAX_SUBNORMAL, -1.0f},
{-Float.MIN_VALUE, -1.0f},
{-0.0f, -0.0f},
{+0.0f, +0.0f},
{Float.MIN_VALUE, 1.0f},
{Float_MAX_SUBNORMALmm, 1.0f},
{Float_MAX_SUBNORMAL, 1.0f},
! {FloatConsts.MIN_NORMAL, 1.0f},
{1.0f, 1.0f},
{2.0f, 1.0f},
{Float_MAX_VALUEmm, 1.0f},
{Float.MAX_VALUE, 1.0f},
{infinityF, 1.0f}
--- 1608,1628 ----
int failures = 0;
float testCases [][] = {
{NaNf, NaNf},
{-infinityF, -1.0f},
{-Float.MAX_VALUE, -1.0f},
! {-Float.MIN_NORMAL, -1.0f},
{-1.0f, -1.0f},
{-2.0f, -1.0f},
{-Float_MAX_SUBNORMAL, -1.0f},
{-Float.MIN_VALUE, -1.0f},
{-0.0f, -0.0f},
{+0.0f, +0.0f},
{Float.MIN_VALUE, 1.0f},
{Float_MAX_SUBNORMALmm, 1.0f},
{Float_MAX_SUBNORMAL, 1.0f},
! {Float.MIN_NORMAL, 1.0f},
{1.0f, 1.0f},
{2.0f, 1.0f},
{Float_MAX_VALUEmm, 1.0f},
{Float.MAX_VALUE, 1.0f},
{infinityF, 1.0f}
*** 1639,1659 ****
int failures = 0;
double testCases [][] = {
{NaNd, NaNd},
{-infinityD, -1.0},
{-Double.MAX_VALUE, -1.0},
! {-DoubleConsts.MIN_NORMAL, -1.0},
{-1.0, -1.0},
{-2.0, -1.0},
{-Double_MAX_SUBNORMAL, -1.0},
{-Double.MIN_VALUE, -1.0d},
{-0.0d, -0.0d},
{+0.0d, +0.0d},
{Double.MIN_VALUE, 1.0},
{Double_MAX_SUBNORMALmm, 1.0},
{Double_MAX_SUBNORMAL, 1.0},
! {DoubleConsts.MIN_NORMAL, 1.0},
{1.0, 1.0},
{2.0, 1.0},
{Double_MAX_VALUEmm, 1.0},
{Double.MAX_VALUE, 1.0},
{infinityD, 1.0}
--- 1642,1662 ----
int failures = 0;
double testCases [][] = {
{NaNd, NaNd},
{-infinityD, -1.0},
{-Double.MAX_VALUE, -1.0},
! {-Double.MIN_NORMAL, -1.0},
{-1.0, -1.0},
{-2.0, -1.0},
{-Double_MAX_SUBNORMAL, -1.0},
{-Double.MIN_VALUE, -1.0d},
{-0.0d, -0.0d},
{+0.0d, +0.0d},
{Double.MIN_VALUE, 1.0},
{Double_MAX_SUBNORMALmm, 1.0},
{Double_MAX_SUBNORMAL, 1.0},
! {Double.MIN_NORMAL, 1.0},
{1.0, 1.0},
{2.0, 1.0},
{Double_MAX_VALUEmm, 1.0},
{Double.MAX_VALUE, 1.0},
{infinityD, 1.0}