def Decimal.div_exact
import bend-kit-bignum@0.1.0.0/decimal.bend as Decimalimport Base
import bend-kit-bignum@0.1.0.0/bigint.bend as Big
152# a / b exactly, at the smallest scale that holds it; None for a zero
153# divisor or a repeating quotient (use Rational for those).
154def Decimal.div_exact(a: Decimal, b: Decimal) -> Maybe<&2, Decimal>:
155 match a b:
156 case Decimal{ua, sa} Decimal{ub, sb}:
157 Decimal.from_fraction(Big.BigInt.mul(ua, Decimal.pow10(sb)),
158 Big.BigInt.mul(ub, Decimal.pow10(sa)))
Uses (5)
Used by (0)
No other definition uses this definition.