test/java/lang/Float/BitwiseConversion.java

Print this page

        

*** 23,47 **** /* * @test * @bug 5037596 * @summary Verify bitwise conversion works for non-canonical NaN values * @author Joseph D. Darcy */ import static java.lang.Float.*; - import static sun.misc.FloatConsts.*; public class BitwiseConversion { static int testNanCase(int x) { int errors = 0; // Strip out sign and exponent bits ! int y = x & SIGNIF_BIT_MASK; float values[] = { ! intBitsToFloat(EXP_BIT_MASK | y), ! intBitsToFloat(SIGN_BIT_MASK | EXP_BIT_MASK | y) }; for(float value: values) { if (!isNaN(value)) { throw new RuntimeException("Invalid input " + y + --- 23,49 ---- /* * @test * @bug 5037596 * @summary Verify bitwise conversion works for non-canonical NaN values + * @library ../Math + * @build FloatConsts + * @run main BitwiseConversion * @author Joseph D. Darcy */ import static java.lang.Float.*; public class BitwiseConversion { static int testNanCase(int x) { int errors = 0; // Strip out sign and exponent bits ! int y = x & FloatConsts.SIGNIF_BIT_MASK; float values[] = { ! intBitsToFloat(FloatConsts.EXP_BIT_MASK | y), ! intBitsToFloat(FloatConsts.SIGN_BIT_MASK | FloatConsts.EXP_BIT_MASK | y) }; for(float value: values) { if (!isNaN(value)) { throw new RuntimeException("Invalid input " + y +
*** 58,68 **** } public static void main(String... argv) { int errors = 0; ! for (int i = 0; i < SIGNIFICAND_WIDTH-1; i++) { errors += testNanCase(1<<i); } if (floatToIntBits(Float.POSITIVE_INFINITY) != 0x7F800000) { --- 60,70 ---- } public static void main(String... argv) { int errors = 0; ! for (int i = 0; i < FloatConsts.SIGNIFICAND_WIDTH-1; i++) { errors += testNanCase(1<<i); } if (floatToIntBits(Float.POSITIVE_INFINITY) != 0x7F800000) {