Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting OverflowError: math range error(trying to calculate power of a number) [duplicate]

Tags:

python

math

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.

like image 851
Anvesh Avatar asked Nov 01 '22 03:11

Anvesh


1 Answers

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.

like image 117
Jayanth Koushik Avatar answered Nov 15 '22 05:11

Jayanth Koushik