From 24a7b7ca116f1bfc5f0c8c32d71a6d80e49a11ab Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Mon, 26 Jan 2026 12:45:24 +0100 Subject: [PATCH] 8375285: Addressed the reviewer's comments. --- .../share/classes/java/lang/FdLibm.java | 18 +++++++++--------- .../share/classes/java/lang/Math.java | 8 ++++++-- .../share/classes/java/lang/StrictMath.java | 5 ++++- test/jdk/java/lang/Math/HyperbolicTests.java | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/java.base/share/classes/java/lang/FdLibm.java b/src/java.base/share/classes/java/lang/FdLibm.java index ac3321983b3..71b9dde6136 100644 --- a/src/java.base/share/classes/java/lang/FdLibm.java +++ b/src/java.base/share/classes/java/lang/FdLibm.java @@ -3537,24 +3537,24 @@ final class FdLibm { private static final double huge = 1.0e300; static double compute(double x) { - double t,w; - int hx,ix; + double t, w; + int hx, ix; hx = __HI(x); - ix = hx&0x7fffffff; + ix = hx & 0x7fffffff; if(ix >= 0x7ff00000) { - return x + x; /* x is inf or NaN */ + return x + x; // x is inf or NaN } - if(ix < 0x3e300000) { /* |x| < 2**-28 */ + if(ix < 0x3e300000) { // |x| < 2**-28 if(huge + x > 1.0) { - return x; /* return x inexact except 0 */ + return x; // return x inexact except 0 } } - if(ix > 0x41b00000) { /* |x| > 2**28 */ + if(ix > 0x41b00000) { // |x| > 2**28 w = Log.compute(Math.abs(x)) + ln2; - } else if (ix > 0x40000000) { /* 2**28 > |x| > 2.0 */ + } else if (ix > 0x40000000) { // 2**28 > |x| > 2.0 t = Math.abs(x); w = Log.compute(2.0 * t + 1.0 / (Sqrt.compute(x * x + 1.0) + t)); - } else { /* 2.0 > |x| > 2**-28 */ + } else { // 2.0 > |x| > 2**-28 t = x * x; w = Log1p.compute(Math.abs(x) + t / (1.0 + Sqrt.compute(1.0 + t))); } diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java index 0ca5ac853af..5e4dd2527b8 100644 --- a/src/java.base/share/classes/java/lang/Math.java +++ b/src/java.base/share/classes/java/lang/Math.java @@ -2770,10 +2770,14 @@ public final class Math { * same sign as the argument. * *
  • If the argument is positive infinity, then the result is - * positive infinity + * positive infinity. * *
  • If the argument is negative infinity, then the result is - * negative infinity + * negative infinity. + * + *
  • If the argument is NaN, then the result is NaN. + * + *

    The computed result must be within 2.5 ulps of the exact result. * * * @param x The number whose inverse hyperbolic sine is to be returned. diff --git a/src/java.base/share/classes/java/lang/StrictMath.java b/src/java.base/share/classes/java/lang/StrictMath.java index 6ea57061816..85940756a63 100644 --- a/src/java.base/share/classes/java/lang/StrictMath.java +++ b/src/java.base/share/classes/java/lang/StrictMath.java @@ -76,7 +76,8 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; * {@code exp}, {@code log}, {@code log10}, * {@code cbrt}, {@code atan2}, {@code pow}, * {@code sinh}, {@code cosh}, {@code tanh}, - * {@code hypot}, {@code expm1}, and {@code log1p}. + * {@code asinh}, {@code hypot}, {@code expm1}, + * and {@code log1p}. * *

    * The platform uses signed two's complement integer arithmetic with @@ -2187,6 +2188,8 @@ public final class StrictMath { *

  • If the argument is negative infinity, then the result is * negative infinity * + *
  • If the argument is NaN, then the result is NaN. + * * * @param x The number whose inverse hyperbolic sine is to be returned. * @return The inverse hyperbolic sine of {@code x}. diff --git a/test/jdk/java/lang/Math/HyperbolicTests.java b/test/jdk/java/lang/Math/HyperbolicTests.java index 770feb8c47e..ed72f52ff3d 100644 --- a/test/jdk/java/lang/Math/HyperbolicTests.java +++ b/test/jdk/java/lang/Math/HyperbolicTests.java @@ -1573,7 +1573,7 @@ public class HyperbolicTests { double d = Math.scalb(2.0, i); // Result and expected are the same. - failures += testAsinhCaseWithUlpDiff(d, d, 2.5); + failures += testAsinhCaseWithUlpDiff(d, d, 3.0); } failures += testAsinhAdditionalTests();