diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-12-16 10:21:30 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-12-16 14:19:55 +0000 |
commit | 6658f0f179ca22526631735194faa5d2c5559bf8 (patch) | |
tree | 88ea37380767a87c4bede306e87428ceb3e129c8 | |
parent | 8e038f4a930c0c899e599ee58a56391e026a608f (diff) | |
download | numpy-6658f0f179ca22526631735194faa5d2c5559bf8.tar.gz |
DOC: Add a brief explanation of float printing
Also link to the overflow docs here.
-rw-r--r-- | doc/source/reference/arrays.scalars.rst | 24 | ||||
-rw-r--r-- | doc/source/user/basics.types.rst | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/doc/source/reference/arrays.scalars.rst b/doc/source/reference/arrays.scalars.rst index 29438f70f..c3fb1f91b 100644 --- a/doc/source/reference/arrays.scalars.rst +++ b/doc/source/reference/arrays.scalars.rst @@ -108,6 +108,11 @@ Integer types :members: __init__ :exclude-members: __init__ +.. note:: + + The numpy integer types mirror the behavior of C integers, and can therefore + be subject to :ref:`overflow-errors`. + Signed integer types ++++++++++++++++++++ @@ -169,6 +174,25 @@ Inexact types :members: __init__ :exclude-members: __init__ +.. note:: + + The printing behavior of inexact scalars is to use as few digits as possible + to display the result unambiguously. This means that equal values at + different precisions will display differently:: + + >>> f16 = np.float16("0.1") + >>> f32 = np.float32(f16) + >>> f64 = np.float64(f32) + >>> f16 == f32 == f64 + True + >>> f16, f32, f64 + (0.1, 0.099975586, 0.0999755859375) + + Note that none of these floats hold the exact value :math:`\frac{1}{10}`; + ``f16`` prints as ``0.1`` because it is as close to that value as possible, + whereas the other types do not as they have more precision and therefore have + closer values. + Floating-point types ++++++++++++++++++++ diff --git a/doc/source/user/basics.types.rst b/doc/source/user/basics.types.rst index ec2af409a..781dd66e5 100644 --- a/doc/source/user/basics.types.rst +++ b/doc/source/user/basics.types.rst @@ -261,6 +261,8 @@ identical behaviour between arrays and scalars, irrespective of whether the value is inside an array or not. NumPy scalars also have many of the same methods arrays do. +.. _overflow-errors: + Overflow Errors =============== |