March Docs

BigInt

BigInt module: arbitrary-precision integers.

Representation: BigInt(sign, digits) where sign : Bool — true = non-negative, false = negative digits : List(Int) — little-endian base-10000 digit list (least significant limb first) BigInt(true, Nil) represents zero.

Base 10000 is convenient: each limb stores 4 decimal digits, so to_string is straightforward without requiring integer logarithms.

Interface implementations: impl Eq(BigInt) — eq/2, == impl Ord(BigInt) — compare/2, < impl Show(BigInt) — show/1

Types

ptypeBigIntBigInt = BigInt(Bool, List(Int))#

Functions

fnzerozero() : BigInt#

Returns BigInt zero.

fnoneone() : BigInt#

Returns BigInt one.

fnfrom_intfrom_int(n : Int) : BigInt#

Converts a native Int to BigInt.

fnaddadd(a : BigInt, b : BigInt) : BigInt#

Adds two BigInts.

fnsubsub(a : BigInt, b : BigInt) : BigInt#

Subtracts b from a.

fnnegatenegate(a : BigInt) : BigInt#

Negates a BigInt.

fnmulmul(a : BigInt, b : BigInt) : BigInt#

Multiplies two BigInts.

fndivdiv(a : BigInt, b : BigInt) : BigInt#

Divides a by b (integer division, truncates toward zero). Panics if b is zero.

fnmod_mod_(a : BigInt, b : BigInt) : BigInt#

Computes a mod b (remainder, same sign as a). Panics if b is zero.

fncomparecompare(a : BigInt, b : BigInt) : Int#

Compares two BigInts. Returns -1 (a < b), 0 (a == b), or 1 (a > b).

fneqeq(a : BigInt, b : BigInt) : Bool#

Returns true if a equals b.

fnltlt(a : BigInt, b : BigInt) : Bool#

Returns true if a < b.

fngtgt(a : BigInt, b : BigInt) : Bool#

Returns true if a > b.

fnltelte(a : BigInt, b : BigInt) : Bool#

Returns true if a <= b.

fngtegte(a : BigInt, b : BigInt) : Bool#

Returns true if a >= b.

fnto_stringto_string(n : BigInt) : String#

Converts a BigInt to its decimal string representation.

fnabsabs(n : BigInt) : BigInt#

Returns the absolute value of a BigInt.

fnis_zerois_zero(n : BigInt) : Bool#

Returns true if the BigInt is zero.

fnis_negativeis_negative(n : BigInt) : Bool#

Returns true if the BigInt is negative.

fnis_positiveis_positive(n : BigInt) : Bool#

Returns true if the BigInt is positive (> 0).