Skip to content

aivi.bigint ​

Pure arbitrary-precision integer operations. The MVP exposes one canonical name per operation. Parsing, narrowing to Int, division, and remainder return Option when no value can be produced.

aivi
use aivi.bigint (
    fromInt
    fromText
    toInt
    toText
    add
    sub
    mul
    div
    mod
    pow
    neg
    abs
    cmp
    eq
    gt
    lt
    zero
    one
    negOne
    isZero
    isPositive
    isNegative
)

Conversion ​

FunctionTypeBehavior
fromIntInt -> BigIntWiden an Int without loss
fromTextText -> Option BigIntParse a signed decimal integer
toIntBigInt -> Option IntNarrow when the value fits in Int
toTextBigInt -> TextRender signed decimal text

Arithmetic ​

FunctionTypeBehavior
addBigInt -> BigInt -> BigIntAddition
subBigInt -> BigInt -> BigIntSubtraction
mulBigInt -> BigInt -> BigIntMultiplication
divBigInt -> BigInt -> Option BigIntTruncating division; None for a zero divisor
modBigInt -> BigInt -> Option BigIntRemainder; None for a zero divisor
powBigInt -> Int -> BigIntInteger power; negative exponents currently act as zero
negBigInt -> BigIntNegation
absBigInt -> BigIntAbsolute value

Comparison ​

FunctionTypeBehavior
cmpBigInt -> BigInt -> IntReturn -1, 0, or 1
eqBigInt -> BigInt -> BoolEquality
gtBigInt -> BigInt -> BoolStrict greater-than
ltBigInt -> BigInt -> BoolStrict less-than
isZeroBigInt -> BoolCompare with zero
isPositiveBigInt -> BoolCompare above zero
isNegativeBigInt -> BoolCompare below zero

Constants ​

ValueMeaning
zero0
one1
negOne-1
aivi
use aivi.bigint (
    add
    fromText
    toText
)

type Text -> Text -> Option Text
func combineTotals = left right => (fromText left, fromText right)
 ||> (Some a, Some b) -> Some (toText (add a b))
 ||> _                -> None

(c) 2026 by Andreas Herd