In Python how come math.log10() and math.log2() give correct answer but not math.log()


#1
class Solution:
# @param A : string
# @return an integer
def power(self, A):
    if (int(A)<2):
        return 0
    val=int(A)
    check=math.log(val)/math.log(2)
    if (math.floor(check)==math.ceil(check)):
        return 1
    else:
        return 0

This returns 0 for "5070602400912917605986812821504 whereas if I use math.log10() instead of math.log(), or if I directly use math.log2(). It returns 1.


#2

math. log ( x [, base ])

With one argument, return the natural logarithm of x (to base e ).

With two arguments, return the logarithm of x to the given base , calculated as log(x)/log(base) .

https://docs.python.org/3/library/math.html#power-and-logarithmic-functions

I hope this helps.