test/java/lang/Math/CubeRootTests.java
Print this page
@@ -26,12 +26,10 @@
* @bug 4347132 4939441
* @summary Tests for {Math, StrictMath}.cbrt
* @author Joseph D. Darcy
*/
-import sun.misc.DoubleConsts;
-
public class CubeRootTests {
private CubeRootTests(){}
static final double infinityD = Double.POSITIVE_INFINITY;
static final double NaNd = Double.NaN;
@@ -91,46 +89,46 @@
double d = i;
failures += testCubeRootCase(d*d*d, (double)i);
}
// Test cbrt(2^(3n)) = 2^n.
- for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
+ for(int i = 18; i <= Double.MAX_EXPONENT/3; i++) {
failures += testCubeRootCase(Math.scalb(1.0, 3*i),
Math.scalb(1.0, i) );
}
// Test cbrt(2^(-3n)) = 2^-n.
- for(int i = -1; i >= DoubleConsts.MIN_SUB_EXPONENT/3; i--) {
+ for(int i = -1; i >= DoubleUtils.MIN_SUB_EXPONENT/3; i--) {
failures += testCubeRootCase(Math.scalb(1.0, 3*i),
Math.scalb(1.0, i) );
}
// Test random perfect cubes. Create double values with
// modest exponents but only have at most the 17 most
// significant bits in the significand set; 17*3 = 51, which
// is less than the number of bits in a double's significand.
long exponentBits1 =
Double.doubleToLongBits(Math.scalb(1.0, 55)) &
- DoubleConsts.EXP_BIT_MASK;
+ DoubleUtils.EXP_BIT_MASK;
long exponentBits2=
Double.doubleToLongBits(Math.scalb(1.0, -55)) &
- DoubleConsts.EXP_BIT_MASK;
+ DoubleUtils.EXP_BIT_MASK;
for(int i = 0; i < 100; i++) {
// Take 16 bits since the 17th bit is implicit in the
// exponent
double input1 =
Double.longBitsToDouble(exponentBits1 |
// Significand bits
((long) (rand.nextInt() & 0xFFFF))<<
- (DoubleConsts.SIGNIFICAND_WIDTH-1-16));
+ (DoubleUtils.SIGNIFICAND_WIDTH-1-16));
failures += testCubeRootCase(input1*input1*input1, input1);
double input2 =
Double.longBitsToDouble(exponentBits2 |
// Significand bits
((long) (rand.nextInt() & 0xFFFF))<<
- (DoubleConsts.SIGNIFICAND_WIDTH-1-16));
+ (DoubleUtils.SIGNIFICAND_WIDTH-1-16));
failures += testCubeRootCase(input2*input2*input2, input2);
}
// Directly test quality of implementation properties of cbrt
// for values that aren't perfect cubes. Verify returned
@@ -238,11 +236,11 @@
double pcNeighbors[] = new double[5];
double pcNeighborsCbrt[] = new double[5];
double pcNeighborsStrictCbrt[] = new double[5];
// Test near cbrt(2^(3n)) = 2^n.
- for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
+ for(int i = 18; i <= Double.MAX_EXPONENT/3; i++) {
double pc = Math.scalb(1.0, 3*i);
pcNeighbors[2] = pc;
pcNeighbors[1] = Math.nextDown(pc);
pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);
@@ -277,11 +275,11 @@
}
}
// Test near cbrt(2^(-3n)) = 2^-n.
- for(int i = -1; i >= DoubleConsts.MIN_SUB_EXPONENT/3; i--) {
+ for(int i = -1; i >= DoubleUtils.MIN_SUB_EXPONENT/3; i--) {
double pc = Math.scalb(1.0, 3*i);
pcNeighbors[2] = pc;
pcNeighbors[1] = Math.nextDown(pc);
pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);