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 @@ -977,9 +977,13 @@ is_error(double x)
977
977
* On some platforms (Ubuntu/ia64) it seems that errno can be
978
978
* set to ERANGE for subnormal results that do *not* underflow
979
979
* to zero. So to be safe, we'll ignore ERANGE whenever the
980
- * function result is less than one in absolute value.
980
+ * function result is less than 1.5 in absolute value.
981
+ *
982
+ * bpo-46018: Changed to 1.5 to ensure underflows in expm1()
983
+ * are correctly detected, since the function may underflow
984
+ * toward -1.0 rather than 0.0.
981
985
*/
982
- if (fabs (x ) < 1.0 )
986
+ if (fabs (x ) < 1.5 )
983
987
result = 0 ;
984
988
else
985
989
PyErr_SetString (PyExc_OverflowError ,
You can’t perform that action at this time.
0 commit comments