test/java/lang/Math/Tests.java

Print this page

        

*** 28,40 **** * success. The order of arguments to the test methods is generally * the test name, followed by the test arguments, the computed result, * and finally the expected result. */ - import sun.misc.FloatConsts; - import sun.misc.DoubleConsts; - public class Tests { private Tests(){}; // do not instantiate public static String toHexString(float f) { if (!Float.isNaN(f)) --- 28,37 ----
*** 79,95 **** */ public static int ilogb(double d) { int exponent = Math.getExponent(d); switch (exponent) { ! case DoubleConsts.MAX_EXPONENT+1: // NaN or infinity if( Double.isNaN(d) ) return (1<<30); // 2^30 else // infinite value return (1<<28); // 2^28 ! case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal if(d == 0.0) { return -(1<<28); // -(2^28) } else { long transducer = Double.doubleToRawLongBits(d); --- 76,92 ---- */ public static int ilogb(double d) { int exponent = Math.getExponent(d); switch (exponent) { ! case Double.MAX_EXPONENT+1: // NaN or infinity if( Double.isNaN(d) ) return (1<<30); // 2^30 else // infinite value return (1<<28); // 2^28 ! case Double.MIN_EXPONENT-1: // zero or subnormal if(d == 0.0) { return -(1<<28); // -(2^28) } else { long transducer = Double.doubleToRawLongBits(d);
*** 115,132 **** transducer *= 2; exponent--; } exponent++; assert( exponent >= ! DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) && ! exponent < DoubleConsts.MIN_EXPONENT); return exponent; } default: ! assert( exponent >= DoubleConsts.MIN_EXPONENT && ! exponent <= DoubleConsts.MAX_EXPONENT); return exponent; } } /** --- 112,129 ---- transducer *= 2; exponent--; } exponent++; assert( exponent >= ! Double.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) && ! exponent < Double.MIN_EXPONENT); return exponent; } default: ! assert( exponent >= Double.MIN_EXPONENT && ! exponent <= Double.MAX_EXPONENT); return exponent; } } /**
*** 148,164 **** */ public static int ilogb(float f) { int exponent = Math.getExponent(f); switch (exponent) { ! case FloatConsts.MAX_EXPONENT+1: // NaN or infinity if( Float.isNaN(f) ) return (1<<30); // 2^30 else // infinite value return (1<<28); // 2^28 ! case FloatConsts.MIN_EXPONENT-1: // zero or subnormal if(f == 0.0f) { return -(1<<28); // -(2^28) } else { int transducer = Float.floatToRawIntBits(f); --- 145,161 ---- */ public static int ilogb(float f) { int exponent = Math.getExponent(f); switch (exponent) { ! case Float.MAX_EXPONENT+1: // NaN or infinity if( Float.isNaN(f) ) return (1<<30); // 2^30 else // infinite value return (1<<28); // 2^28 ! case Float.MIN_EXPONENT-1: // zero or subnormal if(f == 0.0f) { return -(1<<28); // -(2^28) } else { int transducer = Float.floatToRawIntBits(f);
*** 184,201 **** transducer *= 2; exponent--; } exponent++; assert( exponent >= ! FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) && ! exponent < FloatConsts.MIN_EXPONENT); return exponent; } default: ! assert( exponent >= FloatConsts.MIN_EXPONENT && ! exponent <= FloatConsts.MAX_EXPONENT); return exponent; } } /** --- 181,198 ---- transducer *= 2; exponent--; } exponent++; assert( exponent >= ! Float.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) && ! exponent < Float.MIN_EXPONENT); return exponent; } default: ! assert( exponent >= Float.MIN_EXPONENT && ! exponent <= Float.MAX_EXPONENT); return exponent; } } /**