Serhiy Storchaka <[email protected]> added the comment:
There is no two-argument libm `log`. Two-argument log(x, base) is implemented
as log(x) / log(base). log(base) adds an error.
>>> import math
>>> math.log(2**31, 2)
31.000000000000004
Since two-argument log() doesn't correspond a C function, I think we are free
to use more precise implementation.
We could correct also two-argument logarithms with other bases. For example:
def prec_log(x, y):
a = math.log(x, y)
return a + math.log(x / math.pow(y, a), y)
>>> math.log(3**20, 3)
19.999999999999996
>>> prec_log(3**20, 3)
20.0
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com