diff --git a/tools/math.py b/tools/math.py new file mode 100644 index 0000000..92ad48c --- /dev/null +++ b/tools/math.py @@ -0,0 +1,7 @@ +from decimal import Decimal, ROUND_HALF_UP +from .types import Numeric + + +def round_half_up(number: Numeric) -> int: + """ pythons round() rounds .5 to the *even* number; 0.5 == 0 """ + return int(Decimal(number).to_integral(ROUND_HALF_UP))