Relates :
|
|
Relates :
|
|
Relates :
|
By applying the below patch, both tests (`test/jdk/java/lang/Float/Binary16ConversionNaN.java test/jdk/java/lang/Float/Binary16Conversion.java`) still passed. Either we need to improve the tests, or we could simplify the logic as this patch. Seems we need to improve the tests, but I'm not sure, so file this bug to discuss it. Please help to share your points. Thanks! diff --git a/src/java.base/share/classes/java/lang/Float.java b/src/java.base/share/classes/java/lang/Float.java index 7508c22d7f4..f96e23b568e 100644 --- a/src/java.base/share/classes/java/lang/Float.java +++ b/src/java.base/share/classes/java/lang/Float.java @@ -1108,9 +1108,7 @@ public static short floatToFloat16(float f) { // Preserve high order bit of float NaN in the // binary16 result NaN (tenth bit); OR in remaining // bits into lower 9 bits of binary 16 significand. - | (doppel & 0x007f_e000) >> 13 // 10 bits - | (doppel & 0x0000_1ff0) >> 4 // 9 bits - | (doppel & 0x0000_000f)); // 4 bits + | (doppel & 0x007f_e000) >> 13); // 10 bits } float abs_f = Math.abs(f); BTW, I did not find the specific content about this conversion in https://iremi.univ-reunion.fr/IMG/pdf/ieee-754-2008.pdf. Or maybe I missed the information?
|