RFR: 8339934: Simplify Math.scalb(double) method [v2]
Joe Darcy
darcy at openjdk.org
Fri Sep 13 18:47:05 UTC 2024
On Fri, 13 Sep 2024 08:56:39 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> `Math.scalb(double)` can be simplified, removing a loop and using larger/smaller factors.
>
> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>
> Slight improvement.
src/java.base/share/classes/java/lang/Math.java line 3325:
> 3323: if (scaleFactor > -DoubleConsts.EXP_BIAS) {
> 3324: if (scaleFactor <= DoubleConsts.EXP_BIAS) {
> 3325: return d * longBitsToDouble((long) (scaleFactor + DoubleConsts.EXP_BIAS) << PRECISION - 1);
The longBitsToDouble call is basically an inline form of powerOfTwoD. I'd prefer to see that method used for clearer semantics. Optimization of powerOfTwoD would be fine.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20948#discussion_r1759320117
More information about the core-libs-dev
mailing list