summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-09 10:45:41 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-09 10:45:41 (GMT)
commit8f9f8d612a1ee264a465f493b1ce6215418128de (patch)
tree932bbe3ba95806fc499f853fe25c2ec3726c6afa /Modules/mathmodule.c
parent936d518dc8fb8fb094de1391d5a0703287db694e (diff)
downloadcpython-8f9f8d612a1ee264a465f493b1ce6215418128de.zip
cpython-8f9f8d612a1ee264a465f493b1ce6215418128de.tar.gz
cpython-8f9f8d612a1ee264a465f493b1ce6215418128de.tar.bz2
Issue #11888: Use system log2() when available
I expect the system libc to use more accurate functions than Python. The GNU libc uses for example FYL2X and FYL2XP1 hardware instructions on Intel FPU.
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r--Modules/mathmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 14d008a..cebb4ff 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -602,6 +602,9 @@ m_log2(double x)
}
if (x > 0.0) {
+#ifdef HAVE_LOG2
+ return log2(x);
+#else
double m;
int e;
m = frexp(x, &e);
@@ -617,6 +620,7 @@ m_log2(double x)
else {
return log(m) / log(2.0) + e;
}
+#endif
}
else if (x == 0.0) {
errno = EDOM;