I was looking at numpy.finfo
and did the following:
In [14]: np.finfo(np.float16).resolution
Out[14]: 0.0010004
In [16]: np.array([0., 0.0001], dtype=np.float16)
Out[16]: array([ 0. , 0.00010002], dtype=float16)
It seems that the vector is able to store two numbers such that their difference is 10 times smaller than the type's resolution. Am I missing something?
Floating point numbers have a fixed amount of resolution after the initial digit. What this number is telling you is, when the first digit is at the 1.0 position, what is the resolution of the number. You can see this by trying to add smaller amounts to 1.0:
This is related to the
nextafter
function, which gives the next representable number after the given one. Taking that difference gives approximately this resolution: