Skip to main content

Module bigint

Module bigint 

Source
Expand description

Arbitrary-precision signed integer (BigInt).

This is part of the §3.1 “exact computation” foundation. It is a real, self-contained big-integer implementation — sign + little-endian u32 magnitude limbs with schoolbook multiply and long division. It is not a wrapper around i128.

Heap-side is fine here: this is exact arbitrary-precision arithmetic, not a zero-heap hot path. Operations that can fail (division by zero) return an Option/Result and fail closed — they never fabricate a value.

Internal representation invariants:

  • mag holds base-2^32 limbs, little-endian (least significant first).
  • mag is always normalised: no trailing zero limbs. Zero is the empty vector with sign == 0.
  • sign is -1, 0, or +1. sign == 0 iff mag is empty.

Structs§

BigInt
Arbitrary-precision signed integer.