What are the causes of overflow encountered in double_scalars besides division by zero?

Overflow error implies that an operation yields a value out of the range defined for the corresponding data type. For numpy double, that range is (-1.79769313486e+308, 1.79769313486e+308). Also, for a good discussion, please read this SO post.

Example:

import numpy as np
np.seterr(all='warn')
print "Range of numpy double:", np.finfo(np.double).min, np.finfo(np.double).max
A = np.array([143],dtype='double')
a=A[-1]
print "At the border:", a**a
B = np.array([144],dtype='double')
b=B[-1]
print "Blowing out of range:", b**b

Output:

Range of numpy double: -1.79769313486e+308 1.79769313486e+308
At the border: 1.6332525973e+308 
Blowing out of range: inf
D:\anaconda\lib\site-packages\ipykernel\__main__.py:9: RuntimeWarning: overflow encountered in double_scalars

ShareFollow

Leave a Comment