diff options
author | Raphael Kruse <65403623+rk-mlu@users.noreply.github.com> | 2020-05-18 18:22:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 11:22:29 -0500 |
commit | 0eb532de60c9caaaa568ea294e7e1427265b6552 (patch) | |
tree | baa092d0d339bbb9df67f65411e5104ad4975178 /numpy/core/getlimits.py | |
parent | 5e611af4db767f7b038af4a2138f11af5316aa13 (diff) | |
download | numpy-0eb532de60c9caaaa568ea294e7e1427265b6552.tar.gz |
DOC: Calrify tiny/xmin in finfo and machar (gh-16253)
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>
Diffstat (limited to 'numpy/core/getlimits.py')
-rw-r--r-- | numpy/core/getlimits.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py index e2ff49393..f73c21f67 100644 --- a/numpy/core/getlimits.py +++ b/numpy/core/getlimits.py @@ -337,8 +337,8 @@ class finfo: The approximate decimal resolution of this type, i.e., ``10**-precision``. tiny : float - The smallest positive usable number. Type of `tiny` is an - appropriate floating point type. + The smallest positive floating point number with full precision + (see Notes). Parameters ---------- @@ -359,6 +359,18 @@ class finfo: impacts import times. These objects are cached, so calling ``finfo()`` repeatedly inside your functions is not a problem. + Note that ``tiny`` is not actually the smallest positive representable + value in a NumPy floating point type. As in the IEEE-754 standard [1]_, + NumPy floating point types make use of subnormal numbers to fill the + gap between 0 and ``tiny``. However, subnormal numbers may have + significantly reduced precision [2]_. + + References + ---------- + .. [1] IEEE Standard for Floating-Point Arithmetic, IEEE Std 754-2008, + pp.1-70, 2008, http://www.doi.org/10.1109/IEEESTD.2008.4610935 + .. [2] Wikipedia, "Denormal Numbers", + https://en.wikipedia.org/wiki/Denormal_number """ _finfo_cache = {} @@ -546,4 +558,3 @@ class iinfo: def __repr__(self): return "%s(min=%s, max=%s, dtype=%s)" % (self.__class__.__name__, self.min, self.max, self.dtype) - |