Skip to content

Commit 3462a80

Browse files
authored
gh-121889: cmath.acosh(0+nanj) returns nan+pi/2j (#121892)
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.
1 parent 151934a commit 3462a80

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

Lib/test/mathdata/cmath_testcases.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ acosh1002 acosh 0.0 inf -> inf 1.5707963267948966
371371
acosh1003 acosh 2.3 inf -> inf 1.5707963267948966
372372
acosh1004 acosh -0.0 inf -> inf 1.5707963267948966
373373
acosh1005 acosh -2.3 inf -> inf 1.5707963267948966
374-
acosh1006 acosh 0.0 nan -> nan nan
374+
acosh1006 acosh 0.0 nan -> nan 1.5707963267948966 ignore-imag-sign
375375
acosh1007 acosh 2.3 nan -> nan nan
376-
acosh1008 acosh -0.0 nan -> nan nan
376+
acosh1008 acosh -0.0 nan -> nan 1.5707963267948966 ignore-imag-sign
377377
acosh1009 acosh -2.3 nan -> nan nan
378378
acosh1010 acosh -inf 0.0 -> inf 3.1415926535897931
379379
acosh1011 acosh -inf 2.3 -> inf 3.1415926535897931
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adjusts ``cmath.acosh(complex('0+nanj'))`` for recent C standards.

Modules/cmathmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,8 @@ cmath_exec(PyObject *mod)
12591259
INIT_SPECIAL_VALUES(acosh_special_values, {
12601260
C(INF,-P34) C(INF,-P) C(INF,-P) C(INF,P) C(INF,P) C(INF,P34) C(INF,N)
12611261
C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
1262-
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
1263-
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,N)
1262+
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,P12)
1263+
C(INF,-P12) C(U,U) C(0.,-P12) C(0.,P12) C(U,U) C(INF,P12) C(N,P12)
12641264
C(INF,-P12) C(U,U) C(U,U) C(U,U) C(U,U) C(INF,P12) C(N,N)
12651265
C(INF,-P14) C(INF,-0.) C(INF,-0.) C(INF,0.) C(INF,0.) C(INF,P14) C(INF,N)
12661266
C(INF,N) C(N,N) C(N,N) C(N,N) C(N,N) C(INF,N) C(N,N)

0 commit comments

Comments
 (0)