[Numpy-discussion] next NumPy Newcomers' Hour - December 28th, 2023 at 12 PM UTC
Apologies for the late notice! Our next Newcomers' Hour will be held this Thursday, 28th, 2023 at 12 PM UTC, Stop by to ask questions, share your progress, celebrate success, or just to say hi. To add to the meeting agenda the topics you’d like to discuss, follow the link: https://hackmd.io/3f3otyyuTte3FU9y3QzsLg?both. Join the meeting via Zoom: https://us06web.zoom.us/j/82563808729?pwd=ZFU3Z2dMcXBGb05YemRsaGE1OW5nQT09. Thanks, Ganesh ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com
[Numpy-discussion] How is "round to N decimal places" defined for binary floating point numbers?
I have always been puzzled about how to correctly define the python built-in `round(number, ndigits)` when `number` is a binary float and `ndigits` is greater than zero. Apparently CPython and numpy disagree: >>> round(2.765, 2) 2.77 >>> np.round(2.765, 2) 2.76 My question for the numpy devs are: - Is there an authoritative source that explains what `round(number, ndigits)` means when the digits are counted in a base different from the one used in the floating point representation? - Which was the first programming language to implement an intrinsic function `round(number, ndigits)` where ndgits are always decimal, irrespective of the representation of the floating point number? (I’m not interested in algorithms for printing a decimal representation, but in languages that allow to store and perform computations with the rounded value.) - Is `round(number, ndigits)` a useful function that deserves a rigorous definition, or is its use limited to fuzzy situations, where accuracy can be safely traded for speed? Personally I cannot think of sensible uses of `round(number, ndigits)` for binary floats: whenever you positively need `round(number, ndigits)`, you should use a decimal floating point representation. Stefano smime.p7s Description: S/MIME cryptographic signature ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com
[Numpy-discussion] Re: How is "round to N decimal places" defined for binary floating point numbers?
With regard to CPython, there is a recent discussion on this topic: https://discuss.python.org/t/trying-to-understand-rounding-in-python/28014 Le jeu. 28 déc. 2023, à 21 h 43, Stefano Miccoli via NumPy-Discussion < numpy-discussion@python.org> a écrit : > I have always been puzzled about how to correctly define the python > built-in `round(number, ndigits)` when `number` is a binary float and > `ndigits` is greater than zero. > Apparently CPython and numpy disagree: > >>> round(2.765, 2) > 2.77 > >>> np.round(2.765, 2) > 2.76 > > My question for the numpy devs are: > - Is there an authoritative source that explains what `round(number, > ndigits)` means when the digits are counted in a base different from the > one used in the floating point representation? > - Which was the first programming language to implement an intrinsic > function `round(number, ndigits)` where ndgits are always decimal, > irrespective of the representation of the floating point number? (I’m not > interested in algorithms for printing a decimal representation, but in > languages that allow to store and perform computations with the rounded > value.) > - Is `round(number, ndigits)` a useful function that deserves a rigorous > definition, or is its use limited to fuzzy situations, where accuracy can > be safely traded for speed? > > Personally I cannot think of sensible uses of `round(number, ndigits)` for > binary floats: whenever you positively need `round(number, ndigits)`, you > should use a decimal floating point representation. > > Stefano___ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ > Member address: george.tro...@gmail.com > ___ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com