summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-09-14 20:01:15 +0300
committerGitHub <noreply@github.com>2019-09-14 20:01:15 +0300
commit79cb45d9c50875c61f3032f9047f02551661efa1 (patch)
treed563a9d44a4db0711985647ad1829f244bb41542 /numpy/core/fromnumeric.py
parent09d5473f7e9a229cc541362c65f28dab48d18437 (diff)
parentd6d9fafe4f386caea7afd48b6a5774108bfcf577 (diff)
downloadnumpy-79cb45d9c50875c61f3032f9047f02551661efa1.tar.gz
Merge pull request #14503 from ahaldane/tweak_round_docstring
DOC: tweak np.round docstring to clarify floating-point error
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 422ebe2de..140056432 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -3129,11 +3129,10 @@ def around(a, decimals=0, out=None):
``np.around`` uses a fast but sometimes inexact algorithm to round
floating-point datatypes. For positive `decimals` it is equivalent to
- ``np.true_divide(np.rint(a * 10**decimals), 10**decimals)``, which is
- inexact for large floating-point values or large values of `decimals` due
- the inexact representation of decimal fractions in the IEEE floating point
- standard [1]_ and errors introduced when scaling by powers of ten. For
- instance, note the extra "1" in the following:
+ ``np.true_divide(np.rint(a * 10**decimals), 10**decimals)``, which has
+ error due to the inexact representation of decimal fractions in the IEEE
+ floating point standard [1]_ and errors introduced when scaling by powers
+ of ten. For instance, note the extra "1" in the following:
>>> np.round(56294995342131.5, 3)
56294995342131.51
@@ -3154,6 +3153,9 @@ def around(a, decimals=0, out=None):
>>> round(56294995342131.5, 3)
56294995342131.5
+ >>> np.round(16.055, 2), round(16.055, 2) # equals 16.0549999999999997
+ (16.06, 16.05)
+
References
----------