def Decimal.div_exact

bend-kit-bignum@0.1.0.0 · decimal.bend:152

import bend-kit-bignum@0.1.0.0/decimal.bend as Decimal
import 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.