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