[issue36493] Add math.midpoint(a,b) function

2019-04-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: I see this has been rejected for the math module, but I wonder whether it should be considered for Decimal? I recall Mark Dickinson demonstrating this lovely little bit of behaviour: py> from decimal import getcontext, Decimal py> getcontext().prec = 3 py>

[issue36493] Add math.midpoint(a,b) function

2019-04-01 Thread Stefan Behnel
Stefan Behnel added the comment: I buy the YAGNI argument and won't fight for this. Thanks for your input. -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker __

[issue36493] Add math.midpoint(a,b) function

2019-04-01 Thread Tim Peters
Tim Peters added the comment: I'm inclined to agree with Mark - the wholly naive algorithm is already "perfect" away from extreme (whether large or small) magnitudes, and can't be beat for speed either. This kind of thing gets much more attractive in IEEE single precision, where getting nea

[issue36493] Add math.midpoint(a,b) function

2019-04-01 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +tim.peters ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue36493] Add math.midpoint(a,b) function

2019-04-01 Thread Mark Dickinson
Mark Dickinson added the comment: Special cases aside, I think this is a YAGNI. The "obvious" formulas `(a + b)/2)` and `0.5 * (a + b)` _do_ do exactly the right thing (including giving a perfectly correctly-rounded answer with round-ties-to-even on a typical IEEE 754-using machine) provided

[issue36493] Add math.midpoint(a,b) function

2019-04-01 Thread Mark Dickinson
Mark Dickinson added the comment: Yes, I'd definitely expect `midpoint(inf, -inf)` to be `nan`. -- ___ Python tracker ___ ___ Pytho

[issue36493] Add math.midpoint(a,b) function

2019-03-31 Thread Christian Heimes
Christian Heimes added the comment: What's the argument for midpoint(inf, -inf) == 0? This feels wrong to me. I'm certainly not an expert on math, but I still remember that there are different kinds of infinities. For examples 'n**n' approaches infinity 'faster' than '-(2**n)'. -- n

[issue36493] Add math.midpoint(a,b) function

2019-03-31 Thread Stefan Behnel
New submission from Stefan Behnel : I recently read a paperĀ¹ about the difficulty of calculating the most exact midpoint between two floating point values, facing overflow, underflow and rounding errors. The intention is to assure that the midpoint(a,b) is - actually within the interval [a,b]