On Jan 4, 2008 10:16 PM, <[EMAIL PROTECTED]> wrote: > On 4 Jan, 10:45 pm, [EMAIL PROTECTED] wrote: > >[GvR to Tim] > >>Do you have an opinion as to whether we should > >>adopt round-to-even at all (as a default)? > > > >For the sake of other implementations (Jython, etc) and for ease of > >reproducing the results with other tools (Excel, etc), the simplest > >choice is int(x+0.5). That works everywhere, it is easy to explain, it > >runs fast, and it is not hard to get right. > > I agree for the default. Except the part where Excel, Jython, and > Python's current round, actually use sign(x) * int(abs(x)+0.5), so maybe > it's not *completely* easy to get right ;-). > > Having other rounding methods *available*, though, would be neat. The > only application I've ever worked on where I cared about the difference, > the user had to select it (since accounting requirements differ by > jurisdiction and, apparently, by bank preference). Having a standard > way to express this (especially if it worked across different numeric > types, but perhaps I digress) would be pleasant. Implementing > stochastic rounding and banker's rounding oneself, while not exactly > hard, is a drag.
The decimal module already supports rounding modes in its context. For other types, perhaps converting to decimal might be good enough? -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com