Skip to content

Commit

Permalink
8313875: Use literals instead of static fields in java.util.Math: two…
Browse files Browse the repository at this point in the history
…ToTheDoubleScaleUp, twoToTheDoubleScaleDown

Reviewed-by: redestad, darcy, bpb, rgiulietti
  • Loading branch information
Andrey Turbanov committed Aug 8, 2023
1 parent 091e65e commit 41bdcde
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/java.base/share/classes/java/lang/Math.java
Original file line number Diff line number Diff line change
Expand Up @@ -3346,12 +3346,12 @@ public static double scalb(double d, int scaleFactor) {
if(scaleFactor < 0) {
scaleFactor = Math.max(scaleFactor, -MAX_SCALE);
scale_increment = -512;
exp_delta = twoToTheDoubleScaleDown;
exp_delta = 0x1p-512;
}
else {
scaleFactor = Math.min(scaleFactor, MAX_SCALE);
scale_increment = 512;
exp_delta = twoToTheDoubleScaleUp;
exp_delta = 0x1p512;
}

// Calculate (scaleFactor % +/-512), 512 = 2^9, using
Expand Down Expand Up @@ -3420,10 +3420,6 @@ public static float scalb(float f, int scaleFactor) {
return (float)((double)f*powerOfTwoD(scaleFactor));
}

// Constants used in scalb
static double twoToTheDoubleScaleUp = powerOfTwoD(512);
static double twoToTheDoubleScaleDown = powerOfTwoD(-512);

/**
* Returns a floating-point power of two in the normal range.
*/
Expand Down

1 comment on commit 41bdcde

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.