summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-11-01 21:51:15 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-11-01 21:51:15 (GMT)
commitfaf0cd21edde392d4d30e2e4f7d9fa2fb9973b71 (patch)
tree5205cc61cb3cb7d64abbca29bf78e5961857f7a3 /Objects
parent3133f4193763314389930378feec3fd5a4d9d20c (diff)
downloadcpython-faf0cd21edde392d4d30e2e4f7d9fa2fb9973b71.zip
cpython-faf0cd21edde392d4d30e2e4f7d9fa2fb9973b71.tar.gz
cpython-faf0cd21edde392d4d30e2e4f7d9fa2fb9973b71.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/floatobject.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 82aa963..1efef4b 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -568,12 +568,7 @@ float_pos(PyFloatObject *v)
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