RFR: JDK-8289551: Conversions between bit representations of half precision values and floats [v5]

Raffaello Giulietti duke at openjdk.org
Thu Jul 21 21:58:14 UTC 2022


On Thu, 21 Jul 2022 21:22:19 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> Initial implementation.
>
> Joe Darcy has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 20 additional commits since the last revision:
> 
>  - Method rename.
>  - Merge branch 'master' into JDK-8289551
>  - Respond to review feedback; improve tests.
>  - Add NaN test.
>  - Preserve NaN sign bit.
>  - Respond to review feedback.
>  - Correct carry-out bug; add full binade test.
>  - Improve NaN significand fidelity; refine tests.
>  - Partial implementation of review feedback; test refinement.
>  - Merge branch 'master' into JDK-8289551
>  - ... and 10 more: https://git.openjdk.org/jdk/compare/6cc2c3a9...9b060185

src/java.base/share/classes/java/lang/Float.java line 1141:

> 1139:                 // propagate all the way up, take the bottom 11 bits
> 1140:                 // rather than bottom 10 bits. Adding this value,
> 1141:                 // rather than OR'ing htis value, will cause the right

`htis` -> `this`

src/java.base/share/classes/java/lang/Float.java line 1173:

> 1171:                 int sticky = doppel & 0x0000_0fff;
> 1172: 
> 1173:                 if (round != 0 && (lsb != 0 || sticky != 0 )) {

You may want to reverse the order of `(lsb != 0 || sticky != 0)` to `(sticky != 0 || lsb != 0)` to improve the likelihood that the evaluation of `||` does not need to evaluate its right-hand side.
Statistically, `sticky != 0` has a much higher chance to evaluate to `true` than `lsb != 0`.

-------------

PR: https://git.openjdk.org/jdk/pull/9422


More information about the core-libs-dev mailing list