Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from .math_big_integer import parse_big_integer ← from math.big-integer ^1.0.0 · built alongside by fune
from .math_round_div import RoundingMode, round_div ← from math.round-div ^1.0.0 · built alongside by fune
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))