RFR: JDK-8304423: Refactor FdLibm.java
Joe Darcy
darcy at openjdk.org
Mon Apr 24 16:42:59 UTC 2023
On Mon, 24 Apr 2023 12:00:58 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> Minor refactoring of FdLibm.java; will consider future refactorings with more substantive code changes in the future.
>
> src/java.base/share/classes/java/lang/FdLibm.java line 76:
>
>> 74: private static final int SIGN_BIT = 0x8000_0000;
>> 75: private static final int EXP_BITS = 0x7ff0_0000;
>> 76: private static final int EXP_SIGNIF_BITS = 0x7fff_ffff;
>
> These could be expressed in terms of the constants in `Double`. But perhaps it's not worth doing so, after all, as the reader is assumed to be quite knowledgeable.
>
> Otherwise LGTM.
Yes, I had considered expressing these FDLIBM-internal constants in terms of constants from Double or the JDK-internal class DoubleConsts, where they could be more directly expressible based on 64-bit versions of the values. However, I thought having the constants be more directly assigned in this context would be fine.
If these assignments were to be amended, something like adding a static initializer block with asserts might be okay along the lines of
assert SIGN_BIT == (int)(DoubleConsts.SIGN_BIT_MASK >>> 32) &&
EXP_BITS == (int)(DoubleConsts.EXP_BIT_MASK >>> 32) ... ;
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13604#discussion_r1175542650
More information about the core-libs-dev
mailing list