Compare commits
2 Commits
24cd561370
...
e06e536292
| Author | SHA1 | Date | |
|---|---|---|---|
| e06e536292 | |||
| dd39c90f13 |
@ -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))
|
||||
@ -26,3 +34,7 @@ def mul(ints: Iterable[int]) -> int:
|
||||
ret *= x
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def magnitude(value: int | float) -> int:
|
||||
return math.floor(math.log10(value))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user