+4 votes
in Programming Languages by (51.8k points)

I am trying the following power operation, but I get the wrong answer. How can I fix it?

>>> np.power(100,50)


1 Answer

+2 votes
by (281k points)

By default, the power() function uses 64-bit integer dtype. It is too small for such a big number. You need to use float64 dtype that offers a larger but inexact, range of possible values.

Here is the fix:

>>> np.power(100,50, dtype=np.float64)