[Python-Dev] Change in Python 3's "round" behavior

Chris Angelico rosuav at gmail.com
Sun Sep 30 18:27:36 EDT 2018


On Mon, Oct 1, 2018 at 8:17 AM Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Chris Angelico wrote:
> > ]That
> > means that any representable number actually has to indicate a range
> > of values centered on that value.
>
> That's not always true -- it depends on the source of the
> information. For example, a reading of 5 seconds on a clock
> with 1 second resolution actually represents a value between
> 5 and 6 seconds.
>
> So if you're fussy about rounding, you might want to round
> clock readings differently from measurements on a ruler.

True. I gave a number of assumptions, and if those assumptions don't
hold, you may need to vary things. If you have something like you
describe here, you probably want to round-to-zero or something.

ChrisA


More information about the Python-Dev mailing list