Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5ca6c7

Browse files
committed
loghelper(): Try to nudge the compiler into doing mults in an order that
minimizes roundoff error.
1 parent 6fd0f0a commit e5ca6c7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/mathmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ loghelper(PyObject* args, double (*func)(double), char *name)
263263
log(x) + log(2) * e * SHIFT.
264264
CAUTION: e*SHIFT may overflow using int arithmetic,
265265
so force use of double. */
266-
x = func(x) + func(2.0) * (double)e * (double)SHIFT;
266+
x = func(x) + (e * (double)SHIFT) * func(2.0);
267267
return PyFloat_FromDouble(x);
268268
}
269269

0 commit comments

Comments
 (0)