-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Output of np.finfo is misleading #16252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@rk-mlu you are right, that is the smallest non-subnormal number, we should maybe add that as a comment in the docs. I suppose we could add a Can you make a PR suggesting a change in the documentation? That would be great! |
@seberg No problem, I will write up a comment for the documentation. |
rk-mlu
added a commit
to rk-mlu/numpy
that referenced
this issue
May 15, 2020
This commit adds a note to the documentation of finfo clarifying that the attribute `tiny` does not represent the smallest positive usable number. Instead it refers to the smallest positive number with there being no leading 0's in the mantisse (normalized floating point number). Alternatively, `tiny` represents the smallest positive floating point number with full precision. The smallest positive subnormal floating point number is typically orders of magnitudes smaller, but has reduced precision since leading 0's in the mantisse are used to allow smaller exponents than indicated by `minexp`. The commit also adds a brief clarification to the docstring of machar. Closes numpy#16252
seberg
pushed a commit
that referenced
this issue
May 18, 2020
This commit adds a note to the documentation of finfo clarifying that the attribute `tiny` does not represent the smallest positive usable number. Instead it refers to the smallest positive number with there being no leading 0's in the mantisse (normalized floating point number). Alternatively, `tiny` represents the smallest positive floating point number with full precision. The smallest positive subnormal floating point number is typically orders of magnitudes smaller, but has reduced precision since leading 0's in the mantisse are used to allow smaller exponents than indicated by `minexp`. The commit also adds a brief clarification to the docstring of machar. Closes #16252 Co-authored-by: Anirudh Subramanian <anirudh2290@apache.org> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It appears to me that either the documentation of
np.finfo()
is somewhat misleading or the functions returns a wrong result for the parametertiny
.According to the doc of
np.finfo()
tiny isAccording to the script below that is not true.
I am not sure if this is really a bug. I suspect that tiny in
np.finfo()
actually refers to the smallest normalized floating-point number. However, the IEEE 754 standard also includes subnormal floating-point numbers. This is also implemented in np.float64. The smallest positive subnormal is2**(-1022)*2**(-52)
. See Wiki.It may make sense to distinguish between these two classes of floats since the latter does not have the full resolution of up to 16 decimals, but may have considerably less precision. However, from my point of view
np.float64
supports subnormals and they are usable numbers. Hence either the documentation should be adapted or a further attribute may be added tonp.finfo
such astiny_norm
vs.tiny_subn
.Reproducing code example:
Output:
Numpy/Python version information:
1.16.2 3.7.5 (default, Apr 19 2020, 20:18:17)
[GCC 9.2.1 20191008]
The text was updated successfully, but these errors were encountered: