From c0905ffa45dd9985b5ba34251a55a767b1f6a078 Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Sun, 24 Jun 2012 07:17:55 -0500 Subject: [PATCH] Showing the effects of rounding as in the documentation for `numpy.around`. A reference to `numpy.around` (which references IEEE 754) could be helpful here. --- intro/numpy/elaborate_arrays.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intro/numpy/elaborate_arrays.rst b/intro/numpy/elaborate_arrays.rst index 86eb3b8c9..19a15ee35 100644 --- a/intro/numpy/elaborate_arrays.rst +++ b/intro/numpy/elaborate_arrays.rst @@ -45,13 +45,13 @@ Forced casts:: Rounding:: - >>> a = np.array([1.7, 1.2, 1.6]) + >>> a = np.array([1.2, 1.5, 1.6, 2.5, 3.5, 4.5]) >>> b = np.around(a) >>> b # still floating-point - array([ 2., 1., 2.]) + array([ 1., 2., 2., 2., 4., 4.]) >>> c = np.around(a).astype(int) >>> c - array([2, 1, 2]) + array([ 1, 2, 2, 2, 4, 4]) Different data type sizes ..........................