RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
Couple of static fields in Math could be declared `final`. - Commit messages: - [PATCH] Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown Changes: https://git.openjdk.org/jdk/pull/14875/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14875&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8313875 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/14875.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14875/head:pull/14875 PR: https://git.openjdk.org/jdk/pull/14875
Re: RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
On Thu, 13 Jul 2023 17:57:16 GMT, Andrey Turbanov wrote: > Couple of static fields in Math could be declared `final`. Looks good and trivial. - Marked as reviewed by redestad (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/14875#pullrequestreview-1565168404
Re: RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
On Thu, 13 Jul 2023 17:57:16 GMT, Andrey Turbanov wrote: > Couple of static fields in Math could be declared `final`. Marked as reviewed by darcy (Reviewer). - PR Review: https://git.openjdk.org/jdk/pull/14875#pullrequestreview-1565476822
Re: RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
On Thu, 13 Jul 2023 17:57:16 GMT, Andrey Turbanov wrote: > Couple of static fields in Math could be declared `final`. +1 - Marked as reviewed by bpb (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/14875#pullrequestreview-1565684801
Re: RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
On Thu, 13 Jul 2023 17:57:16 GMT, Andrey Turbanov 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? - PR Review Comment: https://git.openjdk.org/jdk/pull/14875#discussion_r1286144980
Re: RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
On Mon, 7 Aug 2023 16:43:49 GMT, Raffaello Giulietti 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
Re: RFR: 8313875: Make fields final in java.util.Math: twoToTheDoubleScaleUp, twoToTheDoubleScaleDown
On Mon, 7 Aug 2023 17:35:34 GMT, Andrey Turbanov wrote: >> 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 These static fields seem to be used just once each, so we might as well just replace the usages with the literals and get rid of the fields. - PR Review Comment: https://git.openjdk.org/jdk/pull/14875#discussion_r1286221538