RFR: 8375285: Port fdlibm asinh to Java [v6]

Anton Artemov aartemov at openjdk.org
Wed Feb 4 09:12:23 UTC 2026


On Tue, 3 Feb 2026 14:35:15 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8375285: Added missed link in documentation.
>
> src/java.base/share/classes/java/lang/FdLibm.java line 3518:
> 
>> 3516:      *
>> 3517:      *
>> 3518:      *      asinh(x) is defined so that asinh(sinh(alpha)) = alpha, -INF < alpha < < INF
> 
> Suggestion:
> 
>      *      asinh(x) is defined so that asinh(sinh(alpha)) = alpha, -∞ < alpha < ∞
> 
> ∞ looks better
> < avoids confusing an HTML parser (not sure if it really needed, though)

Addressed.

> src/java.base/share/classes/java/lang/FdLibm.java line 3519:
> 
>> 3517:      *
>> 3518:      *      asinh(x) is defined so that asinh(sinh(alpha)) = alpha, -INF < alpha < < INF
>> 3519:      *      and sinh(asinh(x)) = x, -INF < x  < INF.
> 
> Similarly

Addressed.

> src/java.base/share/classes/java/lang/FdLibm.java line 3520:
> 
>> 3518:      *      asinh(x) is defined so that asinh(sinh(alpha)) = alpha, -INF < alpha < < INF
>> 3519:      *      and sinh(asinh(x)) = x, -INF < x  < INF.
>> 3520:      *      It can be written as asinh(x) = ln(x + sqrt(x^2 + 1)), -INF < x  < INF.
> 
> This is not the formulation in the original fdlibm code.

Thanks for spotting, missed the modulus braces. Addressed.

> src/java.base/share/classes/java/lang/FdLibm.java line 3531:
> 
>> 3529:      *
>> 3530:      * Special cases:
>> 3531:      *      only asinh(0)=0 is exact for finite x.
> 
> Suggestion:
> 
>      *      only asinh(±0) = ±0 is exact for finite x.

Added as suggested.

> src/java.base/share/classes/java/lang/FdLibm.java line 3533:
> 
>> 3531:      *      only asinh(0)=0 is exact for finite x.
>> 3532:      *      asinh(NaN) is NaN
>> 3533:      *      asinh(INF) is INF
> 
> Suggestion:
> 
>      *      asinh(±∞) = ±∞

Added as suggested.

> src/java.base/share/classes/java/lang/FdLibm.java line 3543:
> 
>> 3541:             int hx, ix;
>> 3542:             hx = __HI(x);
>> 3543:             ix = hx & 0x7fffffff;
> 
> Suggestion:
> 
>             ix = hx & 0x7fff_ffff;
> 
> as well as other hexadecimal literals below. It's easier for counting whether the number of hex digits is correct.

Noted!

> src/java.base/share/classes/java/lang/Math.java line 2765:
> 
>> 2763:      * The inverse hyperbolic sine of <i>x</i> is defined to be a function such that
>> 2764:      *  asinh({@linkplain Math#sinh sinh(<i>x</i>)}) = <i>x</i> for any <i>x</i>.
>> 2765:      *  Note that range of the exact asinh is not limited.
> 
> Suggestion:
> 
>      *  Note that domain of the exact asinh is unrestricted.

I addressed it by adding "Note that both range and domain of the exact asinh are unrestricted."

> src/java.base/share/classes/java/lang/Math.java line 2777:
> 
>> 2775:      * <li>If the argument is negative infinity, then the result is
>> 2776:      * negative infinity.
>> 2777:      *
> 
> It is possible to collapse both items into one, as is done for the zero case.

Addressed.

> src/java.base/share/classes/java/lang/StrictMath.java line 2197:
> 
>> 2195:      * @return  The inverse hyperbolic sine of {@code x}.
>> 2196:      * @since 27
>> 2197:      */
> 
> See the comment for Math

Addressed.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762955015
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762954739
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762954466
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762954104
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762953749
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762953420
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762952878
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762952386
PR Review Comment: https://git.openjdk.org/jdk/pull/29273#discussion_r2762952264


More information about the core-libs-dev mailing list