def BigInt.divmod
import bend-kit-bignum@0.1.0.0/bigint.bend as Bigintimport Base
419# Truncates toward zero: the remainder takes the dividend's sign.
420def BigInt.divmod(a: BigInt, b: BigInt) -> Maybe<&1, BigInt & BigInt>:
421 match a b:
422 case BigInt{sa, x} BigInt{sb, Nil{}}:
423 None{}
424 case BigInt{sa, x} BigInt{sb, y}:
425 Some{BigInt.divmod.fin(sa, sb, Mag.divmod(x, y))}