This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ChrisRands
Recipients ChrisRands
Date 2017-02-28.12:30:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488285024.25.0.0499728148151.issue29677@psf.upfronthosting.co.za>
In-reply-to
Content
With a negative integer for ndigits the output from 'round()', for example 'round(3, -2)', is always zero ('0' for 'int.__round__' and '0.0' or '-0.0' for 'float.__round__').

I think either it should raise an exception or the docs should be updated to reflect the current behavior.

The docs are currently silent on this: https://docs.python.org/3/library/functions.html#round

I don't know C, but there appears to be a note in the source about this implying it is the desired behavior but without an explanation: "For ndigits < NDIGITS_MIN, x always rounds to +-0.0.": https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Objects/floatobject.c

Anyway, I can't imagine an actual use case for negative ndigits.
History
Date User Action Args
2017-02-28 12:30:24ChrisRandssetrecipients: + ChrisRands
2017-02-28 12:30:24ChrisRandssetmessageid: <1488285024.25.0.0499728148151.issue29677@psf.upfronthosting.co.za>
2017-02-28 12:30:24ChrisRandslinkissue29677 messages
2017-02-28 12:30:24ChrisRandscreate