Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 20826:3751366c2f39 legacy-trunk
float_abs() again: Guido pointed out that this could screw up in the
presence of NaNs. So pass the issue on to the platform libm fabs();
after all, fabs() is a std C function because you can't implement it
correctly in portable C89.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Thu, 01 Nov 2001 21:51:15 +0000 |
| parents | c7aa332a2ffa |
| children | 95201153251c |
line wrap: on
line diff
--- a/Objects/floatobject.c Thu Nov 01 21:36:48 2001 +0000 +++ b/Objects/floatobject.c Thu Nov 01 21:51:15 2001 +0000 @@ -568,12 +568,7 @@ static PyObject * float_abs(PyFloatObject *v) { - if (v->ob_fval < 0) - return float_neg(v); - else if (v->ob_fval > 0) - return float_pos(v); - else /* ensure abs(-0) is +0 */ - return PyFloat_FromDouble(+0.0); + return PyFloat_FromDouble(fabs(v->ob_fval)); } static int
