[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-03 Thread Tim Peters
Tim Peters added the comment: Thanks, Mark! I didn't even know __round__ had become a dunder method. For the rest, I'll follow StackOverflow - I don't have an instant answer, and the instant answers I _had_ didn't survive second thoughts ;-) --

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-03 Thread Mark Dickinson
Mark Dickinson added the comment: Just for fun, I posted a Stack Overflow question: https://stackoverflow.com/q/62721186/270986 Let's close this here. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-03 Thread Mark Dickinson
Mark Dickinson added the comment: One note: in the original post, not only are the values being tested coming from NumPy's arange, but round(x[i],1) is testing *NumPy's* rounding functionality, not Python's. x[i] has type np.float64, and while np.float64 does inherit from Python's float, it

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Tim Peters
Tim Peters added the comment: Cool! So the only thing surprising to me here is just how far off balance the arange() run was. So I'd like to keep this open long enough for Mark to notice, just in case it's pointing to something fishy in numpy. --

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: If you change the starting point of the rounding away from zero, the bias flips back and forth, which is exactly what I would expect from Banker's Rounding: def check_bias(start): d = 0.001 ne = no = 0 for i in range(1000):

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Tim Peters
Tim Peters added the comment: I assumed Mark would tell us what's up with the arange() oddity, so let's see whether he does. There is no truly good way to generate "evenly spaced" binary floats using a non-representable conceptual decimal delta. The dumbass ;-) way doesn't show a

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thank you for your long and detailed bug report, but please post one issue per bug report. Tim, we agree that the notion of significant figures is irrelevant; is Carlos' even/odd test sufficiently flawed that we should close this bug report, or keep it

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Carlos Neves
Carlos Neves added the comment: Hi Peters, I will pay more attention to the Python docs :) Thank you for your direction. Carlos A. Neves Em qui., 2 de jul. de 2020 às 18:22, Tim Peters escreveu: > > > Tim Peters added the comment: > > For the first, your hardware's binary floating-point

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Tim Peters
Tim Peters added the comment: For the first, your hardware's binary floating-point has no concept of significant trailing zeroes. If you need such a thing, use Python's `decimal` module instead, which does support a "significant trailing zero" concept. You would need an entirely new data

[issue41198] Round built-in function not shows zeros acording significant figures and calculates different numbers of odd and even

2020-07-02 Thread Carlos Neves
New submission from Carlos Neves : Hi, I am observing unexpected behavior with round built-in function about (1) significant figures in analytical methods and (2) number of odd and even numbers obtained by this function. https://docs.python.org/3/library/functions.html#round