RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
Andrey Turbanov
aturbanov at openjdk.org
Mon Aug 7 17:38:30 UTC 2023
On Mon, 7 Aug 2023 16:43:49 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> Couple of static fields in Math could be declared `final`.
>
> src/java.base/share/classes/java/lang/Math.java line 3425:
>
>> 3423: // Constants used in scalb
>> 3424: private static final double twoToTheDoubleScaleUp = powerOfTwoD(512);
>> 3425: private static final double twoToTheDoubleScaleDown = powerOfTwoD(-512);
>
> Aren't these the _literals_ `0x1p512` and `0x1p-512`, respectively?
Whoa. You are right.
public static void main(String[] args) {
System.out.println(twoToTheDoubleScaleUp);
System.out.println(twoToTheDoubleScaleDown);
System.out.println(0x1p512);
System.out.println(0x1p-512);
System.out.println(twoToTheDoubleScaleUp == 0x1p512);
System.out.println(twoToTheDoubleScaleDown == 0x1p-512);
}
1.3407807929942597E154
7.458340731200207E-155
1.3407807929942597E154
7.458340731200207E-155
true
true
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14875#discussion_r1286196598
More information about the core-libs-dev
mailing list