## test/java/lang/Math/CubeRootTests.java

```@@ -23,14 +23,17 @@

/*
* @test
* @bug 4347132 4939441
* @summary Tests for {Math, StrictMath}.cbrt
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.DoubleUtils jdk.testlibrary.FloatUtils
+ * @run main CubeRootTests
* @author Joseph D. Darcy
*/

-import sun.misc.DoubleConsts;
+import static jdk.testlibrary.DoubleUtils.*;

public class CubeRootTests {
private CubeRootTests(){}

static final double infinityD = Double.POSITIVE_INFINITY;
```

```@@ -91,46 +94,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 >= 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)) &
long exponentBits2=
Double.doubleToLongBits(Math.scalb(1.0, -55)) &
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));
+                                       (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));
+                                       (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 +241,11 @@
double pcNeighbors[] = new double[5];
double pcNeighborsCbrt[] = 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 +280,11 @@
}

}

// Test near cbrt(2^(-3n)) = 2^-n.
-            for(int i = -1; i >= DoubleConsts.MIN_SUB_EXPONENT/3; i--) {
+            for(int i = -1; i >= 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]);
```