[issue38703] should we expect round(0.95, 1) to be 1.0, instead of 0.9?

Mark Dickinson report at bugs.python.org
Tue Nov 5 16:07:57 EST 2019


Mark Dickinson <dickinsm at gmail.com> added the comment:

What Serhiy said. round is behaving as intended and as designed here.

Note: you can also see the actual value of a float object easily by using Decimal:

    >>> from decimal import Decimal
    >>> Decimal(0.95)
    Decimal('0.9499999999999999555910790149937383830547332763671875')

... which demonstrates clearly that the value being rounded is closer to 0.9 than to 1.0.

----------
nosy: +mark.dickinson
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38703>
_______________________________________


More information about the Python-bugs-list mailing list