File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change
1
+ Ensure that :func: `math.expm1 ` does not raise on underflow.
Original file line number Diff line number Diff line change @@ -985,9 +985,13 @@ is_error(double x)
985
985
* On some platforms (Ubuntu/ia64) it seems that errno can be
986
986
* set to ERANGE for subnormal results that do *not* underflow
987
987
* to zero. So to be safe, we'll ignore ERANGE whenever the
988
- * function result is less than one in absolute value.
988
+ * function result is less than 1.5 in absolute value.
989
+ *
990
+ * bpo-46018: Changed to 1.5 to ensure underflows in expm1()
991
+ * are correctly detected, since the function may underflow
992
+ * toward -1.0 rather than 0.0.
989
993
*/
990
- if (fabs (x ) < 1.0 )
994
+ if (fabs (x ) < 1.5 )
991
995
result = 0 ;
992
996
else
993
997
PyErr_SetString (PyExc_OverflowError ,
You can’t perform that action at this time.
0 commit comments