RFR: JDK-8289551: Conversions between bit representations of half precision values and floats
Joe Darcy
darcy at openjdk.org
Fri Jul 15 20:54:03 UTC 2022
On Wed, 13 Jul 2022 13:11:33 GMT, Raffaello Giulietti <duke at openjdk.org> wrote:
>> Initial implementation.
>
> src/java.base/share/classes/java/lang/Float.java line 1174:
>
>> 1172:
>> 1173: short result = 0;
>> 1174: result = (short)(((exp + 15) << 10) | signif_bits);
>
> result = (short)(((exp + 15) << 10) + signif_bits);
>
> The final exponent needs to be incremented when `signif_bits == 0x400`. The `|` is not enough for this to happen.
Good catch; I'll correct this bug in the next push.
I'll be adding a test to verify correct rounding of all the values in a binade - the set of floating-point values with the same exponent. That test reveals this issue.
-------------
PR: https://git.openjdk.org/jdk/pull/9422
More information about the core-libs-dev
mailing list