]> granicus.if.org Git - python/commitdiff
loghelper(): Try to nudge the compiler into doing mults in an order that
authorTim Peters <tim.peters@gmail.com>
Wed, 5 Sep 2001 04:33:11 +0000 (04:33 +0000)
committerTim Peters <tim.peters@gmail.com>
Wed, 5 Sep 2001 04:33:11 +0000 (04:33 +0000)
minimizes roundoff error.

Modules/mathmodule.c

index eef8b78c3fab7699dd1532b0abf77ce7152a88ac..c206ddc0314a73715c0ea401d29342ec6c8907da 100644 (file)
@@ -263,7 +263,7 @@ loghelper(PyObject* args, double (*func)(double), char *name)
                   log(x) + log(2) * e * SHIFT.
                   CAUTION:  e*SHIFT may overflow using int arithmetic,
                   so force use of double. */
-               x = func(x) + func(2.0) * (double)e * (double)SHIFT;
+               x = func(x) + (e * (double)SHIFT) * func(2.0);
                return PyFloat_FromDouble(x);
        }