Java Code Examples for sun.misc.FloatConsts#MIN_NORMAL
The following examples show how to use
sun.misc.FloatConsts#MIN_NORMAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IeeeRecommendedTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static int testFloatSignum() { 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.signum(float)", testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.signum(float)", testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]); } return failures; }
Example 2
Source File: IeeeRecommendedTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static int testFloatSignum() { 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.signum(float)", testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.signum(float)", testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]); } return failures; }
Example 3
Source File: IeeeRecommendedTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static int testFloatNextDown() { int failures=0; /* * Each row of testCases represents one test case for nextDown; * the first column is the input and the second column is the * expected result. */ 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++) { failures+=Tests.test("Math.nextDown(float)", testCases[i][0], Math.nextDown(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.nextDown(float)", testCases[i][0], StrictMath.nextDown(testCases[i][0]), testCases[i][1]); } return failures; }
Example 4
Source File: IeeeRecommendedTests.java From hottub with GNU General Public License v2.0 | 5 votes |
public static int testFloatNextUp() { int failures=0; /* * Each row of testCases represents one test case for nextUp; * the first column is the input and the second column is the * expected result. */ 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.nextUp(float)", testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.nextUp(float)", testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]); } return failures; }
Example 5
Source File: IeeeRecommendedTests.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static int testFloatNextUp() { int failures=0; /* * Each row of testCases represents one test case for nextUp; * the first column is the input and the second column is the * expected result. */ 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.nextUp(float)", testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.nextUp(float)", testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]); } return failures; }
Example 6
Source File: IeeeRecommendedTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static int testFloatSignum() { 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.signum(float)", testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.signum(float)", testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]); } return failures; }
Example 7
Source File: IeeeRecommendedTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static int testFloatNextUp() { int failures=0; /* * Each row of testCases represents one test case for nextUp; * the first column is the input and the second column is the * expected result. */ 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.nextUp(float)", testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.nextUp(float)", testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]); } return failures; }
Example 8
Source File: IeeeRecommendedTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static int testFloatSignum() { 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.signum(float)", testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.signum(float)", testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]); } return failures; }
Example 9
Source File: IeeeRecommendedTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static int testFloatNextUp() { int failures=0; /* * Each row of testCases represents one test case for nextUp; * the first column is the input and the second column is the * expected result. */ 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} }; for(int i = 0; i < testCases.length; i++) { failures+=Tests.test("Math.nextUp(float)", testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]); failures+=Tests.test("StrictMath.nextUp(float)", testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]); } return failures; }
Example 10
Source File: IeeeRecommendedTests.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static int testFloatNextAfter() { int failures=0; /* * Each row of the testCases matrix represents one test case * for nexAfter; given the input of the first two columns, the * result in the last column is expected. */ float [][] testCases = { {NaNf, NaNf, NaNf}, {NaNf, 0.0f, NaNf}, {0.0f, NaNf, NaNf}, {NaNf, infinityF, NaNf}, {infinityF, NaNf, NaNf}, {infinityF, infinityF, infinityF}, {infinityF, -infinityF, Float.MAX_VALUE}, {infinityF, 0.0f, Float.MAX_VALUE}, {Float.MAX_VALUE, infinityF, infinityF}, {Float.MAX_VALUE, -infinityF, Float_MAX_VALUEmm}, {Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE}, {Float.MAX_VALUE, 0.0f, Float_MAX_VALUEmm}, {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}, {Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMALmm}, {Float.MIN_VALUE, 0.0f, 0.0f}, {-Float.MIN_VALUE, 0.0f, -0.0f}, {Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE}, {Float.MIN_VALUE, 1.0f, 2*Float.MIN_VALUE}, // Make sure zero behavior is tested {0.0f, 0.0f, 0.0f}, {0.0f, -0.0f, -0.0f}, {-0.0f, 0.0f, 0.0f}, {-0.0f, -0.0f, -0.0f}, {0.0f, infinityF, Float.MIN_VALUE}, {0.0f, -infinityF, -Float.MIN_VALUE}, {-0.0f, infinityF, Float.MIN_VALUE}, {-0.0f, -infinityF, -Float.MIN_VALUE}, {0.0f, Float.MIN_VALUE, Float.MIN_VALUE}, {0.0f, -Float.MIN_VALUE, -Float.MIN_VALUE}, {-0.0f, Float.MIN_VALUE, Float.MIN_VALUE}, {-0.0f, -Float.MIN_VALUE, -Float.MIN_VALUE} }; for(int i = 0; i < testCases.length; i++) { failures += testNextAfterCase(testCases[i][0], testCases[i][1], testCases[i][2]); } return failures; }
Example 11
Source File: Float.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Returns a hexadecimal string representation of the * {@code float} argument. All characters mentioned below are * ASCII characters. * * <ul> * <li>If the argument is NaN, the result is the string * "{@code NaN}". * <li>Otherwise, the result is a string that represents the sign and * magnitude (absolute value) of the argument. If the sign is negative, * the first character of the result is '{@code -}' * ({@code '\u005Cu002D'}); if the sign is positive, no sign character * appears in the result. As for the magnitude <i>m</i>: * * <ul> * <li>If <i>m</i> is infinity, it is represented by the string * {@code "Infinity"}; thus, positive infinity produces the * result {@code "Infinity"} and negative infinity produces * the result {@code "-Infinity"}. * * <li>If <i>m</i> is zero, it is represented by the string * {@code "0x0.0p0"}; thus, negative zero produces the result * {@code "-0x0.0p0"} and positive zero produces the result * {@code "0x0.0p0"}. * * <li>If <i>m</i> is a {@code float} value with a * normalized representation, substrings are used to represent the * significand and exponent fields. The significand is * represented by the characters {@code "0x1."} * followed by a lowercase hexadecimal representation of the rest * of the significand as a fraction. Trailing zeros in the * hexadecimal representation are removed unless all the digits * are zero, in which case a single zero is used. Next, the * exponent is represented by {@code "p"} followed * by a decimal string of the unbiased exponent as if produced by * a call to {@link Integer#toString(int) Integer.toString} on the * exponent value. * * <li>If <i>m</i> is a {@code float} value with a subnormal * representation, the significand is represented by the * characters {@code "0x0."} followed by a * hexadecimal representation of the rest of the significand as a * fraction. Trailing zeros in the hexadecimal representation are * removed. Next, the exponent is represented by * {@code "p-126"}. Note that there must be at * least one nonzero digit in a subnormal significand. * * </ul> * * </ul> * * <table border> * <caption>Examples</caption> * <tr><th>Floating-point Value</th><th>Hexadecimal String</th> * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td> * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td> * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td> * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td> * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td> * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td> * <tr><td>{@code Float.MAX_VALUE}</td> * <td>{@code 0x1.fffffep127}</td> * <tr><td>{@code Minimum Normal Value}</td> * <td>{@code 0x1.0p-126}</td> * <tr><td>{@code Maximum Subnormal Value}</td> * <td>{@code 0x0.fffffep-126}</td> * <tr><td>{@code Float.MIN_VALUE}</td> * <td>{@code 0x0.000002p-126}</td> * </table> * @param f the {@code float} to be converted. * @return a hex string representation of the argument. * @since 1.5 * @author Joseph D. Darcy */ public static String toHexString(float f) { if (Math.abs(f) < FloatConsts.MIN_NORMAL && f != 0.0f ) {// float subnormal // Adjust exponent to create subnormal double, then // replace subnormal double exponent with subnormal float // exponent String s = Double.toHexString(Math.scalb((double)f, /* -1022+126 */ DoubleConsts.MIN_EXPONENT- FloatConsts.MIN_EXPONENT)); return s.replaceFirst("p-1022$", "p-126"); } else // double string will be the same as float string return Double.toHexString(f); }
Example 12
Source File: IeeeRecommendedTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static int testFloatCopySign() { int failures = 0; // testCases[0] are logically positive numbers; // testCases[1] are negative numbers. 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} }; float NaNs[] = {Float.intBitsToFloat(0x7fc00000), // "positive" NaN Float.intBitsToFloat(0xFfc00000)}; // "negative" NaN // Tests shared between raw and non-raw versions for(int i = 0; i < 2; i++) { for(int j = 0; j < 2; j++) { for(int m = 0; m < testCases[i].length; m++) { for(int n = 0; n < testCases[j].length; n++) { // copySign(magnitude, sign) failures+=Tests.test("Math.copySign(float,float)", testCases[i][m],testCases[j][n], Math.copySign(testCases[i][m], testCases[j][n]), (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) ); failures+=Tests.test("StrictMath.copySign(float,float)", testCases[i][m],testCases[j][n], StrictMath.copySign(testCases[i][m], testCases[j][n]), (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) ); } } } } // For rawCopySign, NaN may effectively have either sign bit // while for copySign NaNs are treated as if they always have // a zero sign bit (i.e. as positive numbers) for(int i = 0; i < 2; i++) { for(int j = 0; j < NaNs.length; j++) { for(int m = 0; m < testCases[i].length; m++) { // copySign(magnitude, sign) failures += (Math.abs(Math.copySign(testCases[i][m], NaNs[j])) == Math.abs(testCases[i][m])) ? 0:1; failures+=Tests.test("StrictMath.copySign(float,float)", testCases[i][m], NaNs[j], StrictMath.copySign(testCases[i][m], NaNs[j]), Math.abs(testCases[i][m]) ); } } } return failures; }
Example 13
Source File: IeeeRecommendedTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static int testFloatNextAfter() { int failures=0; /* * Each row of the testCases matrix represents one test case * for nexAfter; given the input of the first two columns, the * result in the last column is expected. */ float [][] testCases = { {NaNf, NaNf, NaNf}, {NaNf, 0.0f, NaNf}, {0.0f, NaNf, NaNf}, {NaNf, infinityF, NaNf}, {infinityF, NaNf, NaNf}, {infinityF, infinityF, infinityF}, {infinityF, -infinityF, Float.MAX_VALUE}, {infinityF, 0.0f, Float.MAX_VALUE}, {Float.MAX_VALUE, infinityF, infinityF}, {Float.MAX_VALUE, -infinityF, Float_MAX_VALUEmm}, {Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE}, {Float.MAX_VALUE, 0.0f, Float_MAX_VALUEmm}, {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}, {Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMALmm}, {Float.MIN_VALUE, 0.0f, 0.0f}, {-Float.MIN_VALUE, 0.0f, -0.0f}, {Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE}, {Float.MIN_VALUE, 1.0f, 2*Float.MIN_VALUE}, // Make sure zero behavior is tested {0.0f, 0.0f, 0.0f}, {0.0f, -0.0f, -0.0f}, {-0.0f, 0.0f, 0.0f}, {-0.0f, -0.0f, -0.0f}, {0.0f, infinityF, Float.MIN_VALUE}, {0.0f, -infinityF, -Float.MIN_VALUE}, {-0.0f, infinityF, Float.MIN_VALUE}, {-0.0f, -infinityF, -Float.MIN_VALUE}, {0.0f, Float.MIN_VALUE, Float.MIN_VALUE}, {0.0f, -Float.MIN_VALUE, -Float.MIN_VALUE}, {-0.0f, Float.MIN_VALUE, Float.MIN_VALUE}, {-0.0f, -Float.MIN_VALUE, -Float.MIN_VALUE} }; for(int i = 0; i < testCases.length; i++) { failures += testNextAfterCase(testCases[i][0], testCases[i][1], testCases[i][2]); } return failures; }
Example 14
Source File: IeeeRecommendedTests.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static int testFloatBooleanMethods() { int failures = 0; float testCases [] = { NaNf, -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 }; for(int i = 0; i < testCases.length; i++) { // isNaN failures+=Tests.test("FpUtils.isNaN(float)", testCases[i], FpUtils.isNaN(testCases[i]), (i ==0)); // isFinite failures+=Tests.test("Float.isFinite(float)", testCases[i], Float.isFinite(testCases[i]), (i >= 3)); // isInfinite failures+=Tests.test("FpUtils.isInfinite(float)", testCases[i], FpUtils.isInfinite(testCases[i]), (i==1 || i==2)); // isUnorderd for(int j = 0; j < testCases.length; j++) { failures+=Tests.test("FpUtils.isUnordered(float, float)", testCases[i],testCases[j], FpUtils.isUnordered(testCases[i],testCases[j]), (i==0 || j==0)); } } return failures; }
Example 15
Source File: Float.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Returns a hexadecimal string representation of the * {@code float} argument. All characters mentioned below are * ASCII characters. * * <ul> * <li>If the argument is NaN, the result is the string * "{@code NaN}". * <li>Otherwise, the result is a string that represents the sign and * magnitude (absolute value) of the argument. If the sign is negative, * the first character of the result is '{@code -}' * ({@code '\u005Cu002D'}); if the sign is positive, no sign character * appears in the result. As for the magnitude <i>m</i>: * * <ul> * <li>If <i>m</i> is infinity, it is represented by the string * {@code "Infinity"}; thus, positive infinity produces the * result {@code "Infinity"} and negative infinity produces * the result {@code "-Infinity"}. * * <li>If <i>m</i> is zero, it is represented by the string * {@code "0x0.0p0"}; thus, negative zero produces the result * {@code "-0x0.0p0"} and positive zero produces the result * {@code "0x0.0p0"}. * * <li>If <i>m</i> is a {@code float} value with a * normalized representation, substrings are used to represent the * significand and exponent fields. The significand is * represented by the characters {@code "0x1."} * followed by a lowercase hexadecimal representation of the rest * of the significand as a fraction. Trailing zeros in the * hexadecimal representation are removed unless all the digits * are zero, in which case a single zero is used. Next, the * exponent is represented by {@code "p"} followed * by a decimal string of the unbiased exponent as if produced by * a call to {@link Integer#toString(int) Integer.toString} on the * exponent value. * * <li>If <i>m</i> is a {@code float} value with a subnormal * representation, the significand is represented by the * characters {@code "0x0."} followed by a * hexadecimal representation of the rest of the significand as a * fraction. Trailing zeros in the hexadecimal representation are * removed. Next, the exponent is represented by * {@code "p-126"}. Note that there must be at * least one nonzero digit in a subnormal significand. * * </ul> * * </ul> * * <table border> * <caption>Examples</caption> * <tr><th>Floating-point Value</th><th>Hexadecimal String</th> * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td> * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td> * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td> * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td> * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td> * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td> * <tr><td>{@code Float.MAX_VALUE}</td> * <td>{@code 0x1.fffffep127}</td> * <tr><td>{@code Minimum Normal Value}</td> * <td>{@code 0x1.0p-126}</td> * <tr><td>{@code Maximum Subnormal Value}</td> * <td>{@code 0x0.fffffep-126}</td> * <tr><td>{@code Float.MIN_VALUE}</td> * <td>{@code 0x0.000002p-126}</td> * </table> * @param f the {@code float} to be converted. * @return a hex string representation of the argument. * @since 1.5 * @author Joseph D. Darcy */ public static String toHexString(float f) { if (Math.abs(f) < FloatConsts.MIN_NORMAL && f != 0.0f ) {// float subnormal // Adjust exponent to create subnormal double, then // replace subnormal double exponent with subnormal float // exponent String s = Double.toHexString(Math.scalb((double)f, /* -1022+126 */ DoubleConsts.MIN_EXPONENT- FloatConsts.MIN_EXPONENT)); return s.replaceFirst("p-1022$", "p-126"); } else // double string will be the same as float string return Double.toHexString(f); }
Example 16
Source File: IeeeRecommendedTests.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static int testFloatBooleanMethods() { int failures = 0; float testCases [] = { NaNf, -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 }; for(int i = 0; i < testCases.length; i++) { // isNaN failures+=Tests.test("FpUtils.isNaN(float)", testCases[i], FpUtils.isNaN(testCases[i]), (i ==0)); // isFinite failures+=Tests.test("Float.isFinite(float)", testCases[i], Float.isFinite(testCases[i]), (i >= 3)); // isInfinite failures+=Tests.test("FpUtils.isInfinite(float)", testCases[i], FpUtils.isInfinite(testCases[i]), (i==1 || i==2)); // isUnorderd for(int j = 0; j < testCases.length; j++) { failures+=Tests.test("FpUtils.isUnordered(float, float)", testCases[i],testCases[j], FpUtils.isUnordered(testCases[i],testCases[j]), (i==0 || j==0)); } } return failures; }
Example 17
Source File: Float.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Returns a hexadecimal string representation of the * {@code float} argument. All characters mentioned below are * ASCII characters. * * <ul> * <li>If the argument is NaN, the result is the string * "{@code NaN}". * <li>Otherwise, the result is a string that represents the sign and * magnitude (absolute value) of the argument. If the sign is negative, * the first character of the result is '{@code -}' * ({@code '\u005Cu002D'}); if the sign is positive, no sign character * appears in the result. As for the magnitude <i>m</i>: * * <ul> * <li>If <i>m</i> is infinity, it is represented by the string * {@code "Infinity"}; thus, positive infinity produces the * result {@code "Infinity"} and negative infinity produces * the result {@code "-Infinity"}. * * <li>If <i>m</i> is zero, it is represented by the string * {@code "0x0.0p0"}; thus, negative zero produces the result * {@code "-0x0.0p0"} and positive zero produces the result * {@code "0x0.0p0"}. * * <li>If <i>m</i> is a {@code float} value with a * normalized representation, substrings are used to represent the * significand and exponent fields. The significand is * represented by the characters {@code "0x1."} * followed by a lowercase hexadecimal representation of the rest * of the significand as a fraction. Trailing zeros in the * hexadecimal representation are removed unless all the digits * are zero, in which case a single zero is used. Next, the * exponent is represented by {@code "p"} followed * by a decimal string of the unbiased exponent as if produced by * a call to {@link Integer#toString(int) Integer.toString} on the * exponent value. * * <li>If <i>m</i> is a {@code float} value with a subnormal * representation, the significand is represented by the * characters {@code "0x0."} followed by a * hexadecimal representation of the rest of the significand as a * fraction. Trailing zeros in the hexadecimal representation are * removed. Next, the exponent is represented by * {@code "p-126"}. Note that there must be at * least one nonzero digit in a subnormal significand. * * </ul> * * </ul> * * <table border> * <caption>Examples</caption> * <tr><th>Floating-point Value</th><th>Hexadecimal String</th> * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td> * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td> * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td> * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td> * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td> * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td> * <tr><td>{@code Float.MAX_VALUE}</td> * <td>{@code 0x1.fffffep127}</td> * <tr><td>{@code Minimum Normal Value}</td> * <td>{@code 0x1.0p-126}</td> * <tr><td>{@code Maximum Subnormal Value}</td> * <td>{@code 0x0.fffffep-126}</td> * <tr><td>{@code Float.MIN_VALUE}</td> * <td>{@code 0x0.000002p-126}</td> * </table> * @param f the {@code float} to be converted. * @return a hex string representation of the argument. * @since 1.5 * @author Joseph D. Darcy */ public static String toHexString(float f) { if (Math.abs(f) < FloatConsts.MIN_NORMAL && f != 0.0f ) {// float subnormal // Adjust exponent to create subnormal double, then // replace subnormal double exponent with subnormal float // exponent String s = Double.toHexString(Math.scalb((double)f, /* -1022+126 */ DoubleConsts.MIN_EXPONENT- FloatConsts.MIN_EXPONENT)); return s.replaceFirst("p-1022$", "p-126"); } else // double string will be the same as float string return Double.toHexString(f); }
Example 18
Source File: IeeeRecommendedTests.java From hottub with GNU General Public License v2.0 | 4 votes |
public static int testFloatNextAfter() { int failures=0; /* * Each row of the testCases matrix represents one test case * for nexAfter; given the input of the first two columns, the * result in the last column is expected. */ float [][] testCases = { {NaNf, NaNf, NaNf}, {NaNf, 0.0f, NaNf}, {0.0f, NaNf, NaNf}, {NaNf, infinityF, NaNf}, {infinityF, NaNf, NaNf}, {infinityF, infinityF, infinityF}, {infinityF, -infinityF, Float.MAX_VALUE}, {infinityF, 0.0f, Float.MAX_VALUE}, {Float.MAX_VALUE, infinityF, infinityF}, {Float.MAX_VALUE, -infinityF, Float_MAX_VALUEmm}, {Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE}, {Float.MAX_VALUE, 0.0f, Float_MAX_VALUEmm}, {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}, {Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMALmm, Float_MAX_SUBNORMALmm}, {Float.MIN_VALUE, 0.0f, 0.0f}, {-Float.MIN_VALUE, 0.0f, -0.0f}, {Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE}, {Float.MIN_VALUE, 1.0f, 2*Float.MIN_VALUE}, // Make sure zero behavior is tested {0.0f, 0.0f, 0.0f}, {0.0f, -0.0f, -0.0f}, {-0.0f, 0.0f, 0.0f}, {-0.0f, -0.0f, -0.0f}, {0.0f, infinityF, Float.MIN_VALUE}, {0.0f, -infinityF, -Float.MIN_VALUE}, {-0.0f, infinityF, Float.MIN_VALUE}, {-0.0f, -infinityF, -Float.MIN_VALUE}, {0.0f, Float.MIN_VALUE, Float.MIN_VALUE}, {0.0f, -Float.MIN_VALUE, -Float.MIN_VALUE}, {-0.0f, Float.MIN_VALUE, Float.MIN_VALUE}, {-0.0f, -Float.MIN_VALUE, -Float.MIN_VALUE} }; for(int i = 0; i < testCases.length; i++) { failures += testNextAfterCase(testCases[i][0], testCases[i][1], testCases[i][2]); } return failures; }
Example 19
Source File: Float.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a hexadecimal string representation of the * {@code float} argument. All characters mentioned below are * ASCII characters. * * <ul> * <li>If the argument is NaN, the result is the string * "{@code NaN}". * <li>Otherwise, the result is a string that represents the sign and * magnitude (absolute value) of the argument. If the sign is negative, * the first character of the result is '{@code -}' * ({@code '\u005Cu002D'}); if the sign is positive, no sign character * appears in the result. As for the magnitude <i>m</i>: * * <ul> * <li>If <i>m</i> is infinity, it is represented by the string * {@code "Infinity"}; thus, positive infinity produces the * result {@code "Infinity"} and negative infinity produces * the result {@code "-Infinity"}. * * <li>If <i>m</i> is zero, it is represented by the string * {@code "0x0.0p0"}; thus, negative zero produces the result * {@code "-0x0.0p0"} and positive zero produces the result * {@code "0x0.0p0"}. * * <li>If <i>m</i> is a {@code float} value with a * normalized representation, substrings are used to represent the * significand and exponent fields. The significand is * represented by the characters {@code "0x1."} * followed by a lowercase hexadecimal representation of the rest * of the significand as a fraction. Trailing zeros in the * hexadecimal representation are removed unless all the digits * are zero, in which case a single zero is used. Next, the * exponent is represented by {@code "p"} followed * by a decimal string of the unbiased exponent as if produced by * a call to {@link Integer#toString(int) Integer.toString} on the * exponent value. * * <li>If <i>m</i> is a {@code float} value with a subnormal * representation, the significand is represented by the * characters {@code "0x0."} followed by a * hexadecimal representation of the rest of the significand as a * fraction. Trailing zeros in the hexadecimal representation are * removed. Next, the exponent is represented by * {@code "p-126"}. Note that there must be at * least one nonzero digit in a subnormal significand. * * </ul> * * </ul> * * <table border> * <caption>Examples</caption> * <tr><th>Floating-point Value</th><th>Hexadecimal String</th> * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td> * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td> * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td> * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td> * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td> * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td> * <tr><td>{@code Float.MAX_VALUE}</td> * <td>{@code 0x1.fffffep127}</td> * <tr><td>{@code Minimum Normal Value}</td> * <td>{@code 0x1.0p-126}</td> * <tr><td>{@code Maximum Subnormal Value}</td> * <td>{@code 0x0.fffffep-126}</td> * <tr><td>{@code Float.MIN_VALUE}</td> * <td>{@code 0x0.000002p-126}</td> * </table> * @param f the {@code float} to be converted. * @return a hex string representation of the argument. * @since 1.5 * @author Joseph D. Darcy */ public static String toHexString(float f) { if (Math.abs(f) < FloatConsts.MIN_NORMAL && f != 0.0f ) {// float subnormal // Adjust exponent to create subnormal double, then // replace subnormal double exponent with subnormal float // exponent String s = Double.toHexString(Math.scalb((double)f, /* -1022+126 */ DoubleConsts.MIN_EXPONENT- FloatConsts.MIN_EXPONENT)); return s.replaceFirst("p-1022$", "p-126"); } else // double string will be the same as float string return Double.toHexString(f); }
Example 20
Source File: Float.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
/** * Returns a hexadecimal string representation of the * {@code float} argument. All characters mentioned below are * ASCII characters. * * <ul> * <li>If the argument is NaN, the result is the string * "{@code NaN}". * <li>Otherwise, the result is a string that represents the sign and * magnitude (absolute value) of the argument. If the sign is negative, * the first character of the result is '{@code -}' * ({@code '\u005Cu002D'}); if the sign is positive, no sign character * appears in the result. As for the magnitude <i>m</i>: * * <ul> * <li>If <i>m</i> is infinity, it is represented by the string * {@code "Infinity"}; thus, positive infinity produces the * result {@code "Infinity"} and negative infinity produces * the result {@code "-Infinity"}. * * <li>If <i>m</i> is zero, it is represented by the string * {@code "0x0.0p0"}; thus, negative zero produces the result * {@code "-0x0.0p0"} and positive zero produces the result * {@code "0x0.0p0"}. * * <li>If <i>m</i> is a {@code float} value with a * normalized representation, substrings are used to represent the * significand and exponent fields. The significand is * represented by the characters {@code "0x1."} * followed by a lowercase hexadecimal representation of the rest * of the significand as a fraction. Trailing zeros in the * hexadecimal representation are removed unless all the digits * are zero, in which case a single zero is used. Next, the * exponent is represented by {@code "p"} followed * by a decimal string of the unbiased exponent as if produced by * a call to {@link Integer#toString(int) Integer.toString} on the * exponent value. * * <li>If <i>m</i> is a {@code float} value with a subnormal * representation, the significand is represented by the * characters {@code "0x0."} followed by a * hexadecimal representation of the rest of the significand as a * fraction. Trailing zeros in the hexadecimal representation are * removed. Next, the exponent is represented by * {@code "p-126"}. Note that there must be at * least one nonzero digit in a subnormal significand. * * </ul> * * </ul> * * <table border> * <caption>Examples</caption> * <tr><th>Floating-point Value</th><th>Hexadecimal String</th> * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td> * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td> * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td> * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td> * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td> * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td> * <tr><td>{@code Float.MAX_VALUE}</td> * <td>{@code 0x1.fffffep127}</td> * <tr><td>{@code Minimum Normal Value}</td> * <td>{@code 0x1.0p-126}</td> * <tr><td>{@code Maximum Subnormal Value}</td> * <td>{@code 0x0.fffffep-126}</td> * <tr><td>{@code Float.MIN_VALUE}</td> * <td>{@code 0x0.000002p-126}</td> * </table> * @param f the {@code float} to be converted. * @return a hex string representation of the argument. * @since 1.5 * @author Joseph D. Darcy */ public static String toHexString(float f) { if (Math.abs(f) < FloatConsts.MIN_NORMAL && f != 0.0f ) {// float subnormal // Adjust exponent to create subnormal double, then // replace subnormal double exponent with subnormal float // exponent String s = Double.toHexString(Math.scalb((double)f, /* -1022+126 */ DoubleConsts.MIN_EXPONENT- FloatConsts.MIN_EXPONENT)); return s.replaceFirst("p-1022$", "p-126"); } else // double string will be the same as float string return Double.toHexString(f); }