Get OverflowError: Mathematical Range Error (when trying to calculate the power of a number)

advertisements

This question already has an answer here:

  • How I can calculate big numbers in python [closed] 3 answers

I am trying to find the exact digit of the expression. which I am unable to find it. Below is the snippet code I have tried.

>>> math.pow(400.0,math.pow(400.0,400.0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error

When I have tried with numpy I was getting like:

>>> np.power(400.0,np.power(400.0,400.0))
>>> inf

But I couldnt get the exact digit. Can anyone help me out with this. It would be a great help for me.

Thanks in Advance.


The number you are trying to calculate has 1.735057357739408×10^1041 decimal digits (from wolframalpha). You most certainly cannot get the exact representation for it. inf is as close as you are going to get.