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

2018-10-02 Thread Mark Lawrence
On 01/10/18 21:45, Michael Felt wrote: On 9/30/2018 2:17 PM, Steven D'Aprano wrote: (It's also called Dutch Rounding.) Ah - as to why - and from school! (as so-called intuitive! rather desired!). A test score goes from 5.5 to 6.0 - which becomes passing. Oh, do I recall my children's

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

2018-10-01 Thread Michael Felt
On 9/30/2018 2:17 PM, Steven D'Aprano wrote: > (It's also called Dutch Rounding.) Ah - as to why - and from school! (as so-called intuitive! rather desired!). A test score goes from 5.5 to 6.0 - which becomes passing. Oh, do I recall my children's frustrations when they had a X.4Y score -

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

2018-09-30 Thread Terry Reedy
On 9/26/2018 7:26 AM, j...@math.brown.edu wrote: To paraphrase: 1. Where was the 3.0 change discussed? 2. What was the rationale? I think these have been answered as well as possible. 3. Can the change be reverted? It 'could be', but will not be reverted? 4. Should something be added to the

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

2018-09-30 Thread Mansour Moufid
On Wed, Sep 26, 2018 at 7:29 AM wrote: > > I recently found out about Python 3's round-to-even change (via > https://github.com/cosmologicon/pywat!) and am having trouble finding > where that change was discussed. That GitHub project is hilarious especially the NaN stuff... Rounding is from

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

2018-09-30 Thread Chris Angelico
On Mon, Oct 1, 2018 at 9:36 AM Steven D'Aprano wrote: > Then we can add a keyword only argument to round: > > round(number, ndigits=0, *, mode=ROUND_HALF_EVEN) > > To use it, you can import the rounding mode you want from math: > > from math import ROUND_CEILING > round(x, 3,

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

2018-09-30 Thread Steven D'Aprano
On Mon, Oct 01, 2018 at 10:50:36AM +1300, Greg Ewing wrote: > Alex Walters wrote: > >Other use case is finance, where you can end up with interest calculations > >that are fractional of the base unit of currency. US$2.345 is impossible > >to > >represent in real currency, so it has to be

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

2018-09-30 Thread Richard Damon
On 9/30/18 6:15 PM, Greg Ewing 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

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

2018-09-30 Thread Chris Angelico
On Mon, Oct 1, 2018 at 8:17 AM Greg Ewing 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

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

2018-09-30 Thread Greg Ewing
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

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

2018-09-30 Thread Greg Ewing
Steven D'Aprano wrote: (It's also called Dutch Rounding.) Oh, so *that's* why Python does it! Fair enough. :-) Similarly for differences. If you perform many subtractions (let's say you are paying off a loan, and calculating interest, then rounding to the nearest cent) you have to care

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

2018-09-30 Thread Greg Ewing
Alex Walters wrote: Other use case is finance, where you can end up with interest calculations that are fractional of the base unit of currency. US$2.345 is impossible to represent in real currency, so it has to be rounded. This brings us back to my original point about floating point

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

2018-09-30 Thread Chris Angelico
On Sun, Sep 30, 2018 at 10:18 PM Steven D'Aprano wrote: > > On Sat, Sep 29, 2018 at 09:40:03PM -0400, Alex Walters wrote: > > My experience and that of many users of > > the python irc channel on freenode is that round-half-to-even is not the > > intuitive, or even desired, behavior -

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

2018-09-30 Thread Steven D'Aprano
On Sat, Sep 29, 2018 at 09:40:03PM -0400, Alex Walters wrote: > ...and we have a stats module that would be a great place for a round > function that needs to cancel rounding errors. This has nothing to do with statistics. You should consider that this is often called "Banker's Rounding" and

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

2018-09-30 Thread Alex Walters
> -Original Message- > From: Python-Dev list=sdamon@python.org> On Behalf Of Greg Ewing > Sent: Saturday, September 29, 2018 9:50 PM > To: python-dev@python.org > Subject: Re: [Python-Dev] Change in Python 3's "round" behavior > > I don't r

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

2018-09-29 Thread Greg Ewing
I don't really get the statistical argument. If you're doing something like calculating an average and care about accuracy, why are you rounding the values before averaging? Why not average first and then round the result if you need to? -- Greg ___

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

2018-09-29 Thread Alex Walters
> -Original Message- > From: Python-Dev list=sdamon@python.org> On Behalf Of Steven D'Aprano > Sent: Thursday, September 27, 2018 9:54 AM > To: python-dev@python.org > Subject: Re: [Python-Dev] Change in Python 3's "round" behavior > > On Thu

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

2018-09-29 Thread Stephen J. Turnbull
Greg Ewing writes: > (BTW, how do you provide a citation for "common knowledge"?-) Aumann, Robert J. [1976], "Agreeing to Disagree." Annals of Statistics 4, pp. 1236-1239 is what I usually use. :-) ___ Python-Dev mailing list Python-Dev@python.org

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

2018-09-27 Thread Steven D'Aprano
On Thu, Sep 27, 2018 at 05:55:07PM +1200, Greg Ewing wrote: > j...@math.brown.edu wrote: > >I understand from > >https://github.com/cosmologicon/pywat/pull/40#discussion_r219962259 > >that "to always round up... can theoretically skew the data" > > *Very* theoretically. If the number is even a

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

2018-09-26 Thread Greg Ewing
j...@math.brown.edu wrote: I understand from https://github.com/cosmologicon/pywat/pull/40#discussion_r219962259 that "to always round up... can theoretically skew the data" *Very* theoretically. If the number is even a whisker bigger than 2.5 it's going to get rounded up regardless: >>>

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

2018-09-26 Thread Steven D'Aprano
On Wed, Sep 26, 2018 at 07:26:17AM -0400, j...@math.brown.edu wrote: > I did find the revealingly-invalid bug report > https://bugs.python.org/issue32956 ("python 3 round bug"), so I asked > there, but wanted to invite anyone else on this list who might be > interested to help. What about those

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

2018-09-26 Thread jab
I recently found out about Python 3's round-to-even change (via https://github.com/cosmologicon/pywat!) and am having trouble finding where that change was discussed. I did find the revealingly-invalid bug report https://bugs.python.org/issue32956 ("python 3 round bug"), so I asked there, but