<分区>
Possible Duplicate:
Inaccurate Logarithm in Python
为什么 math.log10(x)
和 math.log(x,10)
结果不同?
In [1]: from math import *
In [2]: log10(1000)
Out[2]: 3.0
In [3]: log(1000,10)
Out[3]: 2.9999999999999996
<分区>
Possible Duplicate:
Inaccurate Logarithm in Python
为什么 math.log10(x)
和 math.log(x,10)
结果不同?
In [1]: from math import *
In [2]: log10(1000)
Out[2]: 3.0
In [3]: log(1000,10)
Out[3]: 2.9999999999999996
最佳答案
这是一个已知错误:http://bugs.python.org/issue3724
似乎 logX(y) 总是比等效的 log(Y, X) 更精确。
关于Python 数学模块对数函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14577310/