Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4fbcdc

Browse files
committed
Add note about surprising behaviour from round function.
1 parent 7410dd1 commit c4fbcdc

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Doc/library/functions.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,13 @@ are always available. They are listed here in alphabetical order.
972972
The return value is an integer if called with one argument, otherwise of the
973973
same type as *x*.
974974

975+
.. note::
976+
977+
The behavior of :func:`round` for floats can be surprising: for example,
978+
``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``.
979+
This is not a bug: it's a result of the fact that most decimal fractions
980+
can't be represented exactly as a float. See :ref:`tut-fp-issues` for
981+
more information.
975982

976983
.. function:: set([iterable])
977984
:noindex:

0 commit comments

Comments
 (0)