New submission from ChrisRands: 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. ---------- messages: 288710 nosy: ChrisRands priority: normal severity: normal status: open title: 'round()' accepts a negative integer for ndigits _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29677> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com