To answer your question, because floats in Python are IEEE754 floats and have limited precision.
>>> int(10**25.0)
10000000000000000905969664L
As you can see, the answer is close but incorrect.
How can I raise to very large non-integer powers and perform mod on them (e.g. steps taken to perform RSA-like logic using pure math) in Python?
This is my suggestion using x^(a+b) = x^a * x^b
:
def powmod_f(base, exponent, mod):
return (pow(base, int(exponent), mod) * (base ** (exponent % 1))) % mod
This only works with an integer base however, if your base is a float as well you're going to have to implement a powmod algorithm yourself.