From e06e536292578c850cff50d1efab520b5f390110 Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Sat, 7 Dec 2024 06:41:16 +0100 Subject: [PATCH] math: MAXINT* constants --- src/tools/math.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/math.py b/src/tools/math.py index 43553b2..91d1b25 100644 --- a/src/tools/math.py +++ b/src/tools/math.py @@ -4,6 +4,14 @@ from decimal import Decimal, ROUND_HALF_UP from typing import Iterable +MAXINT32 = 2**32 +MAXINT64 = 2**64 +MAXINT32_SIGNED = 2**31 +MAXINT64_SIGNED = 2**63 +MAXINT32_UNSIGNED = MAXINT32 +MAXINT64_UNSIGNED = MAXINT64 + + def round_half_up(number: int | float) -> int: """pythons round() rounds .5 to the *even* number; 0.5 == 0""" return int(Decimal(number).to_integral(ROUND_HALF_UP))