12 Jul
2018
12 Jul
'18
4:11 p.m.
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.)