Im trying to understand the following results:
In [1]: with np.errstate(divide='ignore', invalid='ignore'):
...: for val in 1e-324,2e-324,3e-324:
...: val_by_zero = np.array([val])/0
...: print( val_by_zero, np.nan_to_num(val_by_zero))
...:
...:
[nan] [0.]
[nan] [0.]
[inf] [1.79769313e+308]
In [2]: np.__version__
Out[2]: '1.20.3'
In [3]: np.finfo(np.float64)
Out[3]: finfo(resolution=1e-15, min=-1.7976931348623157e+308, max=1.7976931348623157e+308, dtype=float64)
I am just curious exactly whats going on in within the numpy library that determines whether a float is inf or nan.
This is python 3.8.12 running on CentOS Linux release 7.9.2009.
NOTE: I arrived at the numbers vals=[1e-324, 2e-324, 3e-324] after inspecting an application that was corrupted by unwanted large numbers (e.g. the float max 1.79769313e+308). I imagine that these vals are platform and/or configuration dependent.