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.
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 @@
}
if (x > 0.0) {
+#ifdef HAVE_LOG2
+ return log2(x);
+#else
double m;
int e;
m = frexp(x, &e);
@@ -617,6 +620,7 @@
else {
return log(m) / log(2.0) + e;
}
+#endif
}
else if (x == 0.0) {
errno = EDOM;