from .math_big_integer import parse_big_integer from .math_round_div import RoundingMode, round_div def round_div_big(numerator: str, denominator: str, mode: RoundingMode) -> str: """math.round-div, for integers too big for a JavaScript number. Python's integers never overflow, so this is math.round-div itself; the capability exists so TypeScript and Rust, whose native integers stop at 2^53 and 2^127, give the same answer from the same decimal strings. """ n = parse_big_integer(numerator) d = parse_big_integer(denominator) if mode not in ("half-up", "half-even", "down", "up"): raise ValueError('unknown rounding mode "%s"' % (mode,)) return str(round_div(n, d, mode))