0
$\begingroup$

I am running some test code and observed something strange. the numpy power function giving strange output post 2 to the power 62

p=np.array([1,2,3,50,60,62,63,70,80,99])
np.power(2,p)

The outout of above code is

array([                   2,                    4,                    8,
       1125899906842624,  1152921504606846976,  4611686018427387904,
   -9223372036854775808,                    0,                    0,
                      0])

enter image description here

Curious if someone can explain what is happening here

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Numpy uses C datatype and thus it has limited precision. I guess the highest precision integer in your system is 64-bit. You can refer the documentation of NumPy to get a more detailed answer on overflow errors and extended precision.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.