12.07.18 14:55, Serhiy Storchaka пише:
What are your thoughts about adding a new imath module for integer
mathematics? It could contain the following functions:
I forgot yet one useful function:
def divide_and_round(a, b):
q, r = divmod(a, b)
r *= 2
greater_than_half = r > b if b > 0 else r < b
if greater_than_half or r == b and q % 2 == 1:
q += 1
return q
(This is a copy of the implementation from datetime.py, there are yet
few implementations in Python and C in other files.)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/