]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-121889: cmath.acosh(0+nanj) returns nan+pi/2j (#121892)
authorSergey B Kirpichev <skirpichev@gmail.com>
Sun, 4 Aug 2024 08:53:17 +0000 (11:53 +0300)
committerGitHub <noreply@github.com>
Sun, 4 Aug 2024 08:53:17 +0000 (09:53 +0100)
As per C11 DR#471 (adjusted resolution accepted for C17), cacosh (0 +
iNaN) should return NaN ± i pi/2, not NaN + iNaN.  This patch
fixes cmath's code to do same.

Lib/test/mathdata/cmath_testcases.txt
Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst [new file with mode: 0644]
Modules/cmathmodule.c

index 0165e17634f41c66947676f36c331830ffe25ced..0c0d2d703f07f87f7ff00b06babb6fef263ea2e2 100644 (file)
@@ -371,9 +371,9 @@ acosh1002 acosh 0.0 inf -> inf 1.5707963267948966
 acosh1003 acosh 2.3 inf -> inf 1.5707963267948966
 acosh1004 acosh -0.0 inf -> inf 1.5707963267948966
 acosh1005 acosh -2.3 inf -> inf 1.5707963267948966
-acosh1006 acosh 0.0 nan -> nan nan
+acosh1006 acosh 0.0 nan -> nan 1.5707963267948966         ignore-imag-sign
 acosh1007 acosh 2.3 nan -> nan nan
-acosh1008 acosh -0.0 nan -> nan nan
+acosh1008 acosh -0.0 nan -> nan 1.5707963267948966        ignore-imag-sign
 acosh1009 acosh -2.3 nan -> nan nan
 acosh1010 acosh -inf 0.0 -> inf 3.1415926535897931
 acosh1011 acosh -inf 2.3 -> inf 3.1415926535897931
diff --git a/Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst b/Misc/NEWS.d/next/Library/2024-07-17-09-23-03.gh-issue-121889.6se9jS.rst
new file mode 100644 (file)
index 0000000..a7babe0
--- /dev/null
@@ -0,0 +1 @@
+Adjusts ``cmath.acosh(complex('0+nanj'))`` for recent C standards.
index bf86a211bcb18826721c6e1fc17879706a6de85a..16ac663bdb99491f43b49742a07754aaf9225441 100644 (file)
@@ -1259,8 +1259,8 @@ cmath_exec(PyObject *mod)
     INIT_SPECIAL_VALUES(acosh_special_values, {
       C(INF,-P34) C(INF,-P)  C(INF,-P)  C(INF,P)  C(INF,P)  C(INF,P34) C(INF,N)
       C(INF,-P12) C(U,U)     C(U,U)     C(U,U)    C(U,U)    C(INF,P12) C(N,N)
-      C(INF,-P12) C(U,U)     C(0.,-P12) C(0.,P12) C(U,U)    C(INF,P12) C(N,N)
-      C(INF,-P12) C(U,U)     C(0.,-P12) C(0.,P12) C(U,U)    C(INF,P12) C(N,N)
+      C(INF,-P12) C(U,U)     C(0.,-P12) C(0.,P12) C(U,U)    C(INF,P12) C(N,P12)
+      C(INF,-P12) C(U,U)     C(0.,-P12) C(0.,P12) C(U,U)    C(INF,P12) C(N,P12)
       C(INF,-P12) C(U,U)     C(U,U)     C(U,U)    C(U,U)    C(INF,P12) C(N,N)
       C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
       C(INF,N)    C(N,N)     C(N,N)     C(N,N)    C(N,N)    C(INF,N)   C(N,N)