i/big
Arbitrary precision Int arithmetic beyond the small range (§11.2): the runtime adds, subtracts, multiplies, divides, compares and writes small Ints itself, and calls these functions when an operand is large.
The runtime keeps a large Int as its sign and an array of 32-bit limbs.
This code reads its digits in base 2^30 in place, by index (size,
limb), and writes each result once into private construction storage.
Only the text form works on lists of operand digits
(digits). Digit calculations stay below 2^62, where the runtime
computes in 64 bits. Only Karatsuba composes big arithmetic again,
deliberately, on its smaller subproducts.
The private primitives are not part of the language (§13).
compare
-1, 0 or 1, as a is less than, equal to or greater than b.
compare = (a : Int, b : Int) -> Int { add
a + b.
add = (a : Int, b : Int) -> Int { signed_add(a, sign(a), b, sign(b)) } subtract
a - b.
subtract = (a : Int, b : Int) -> Int { signed_add(a, sign(a), b, -sign(b)) } multiply
a * b.
multiply = (a : Int, b : Int) -> Int { divide
a / b, rounded toward zero; 0 when b is 0 (§11.2).
divide = (a : Int, b : Int) -> Int { remainder
a % b, with the sign of a; 0 when b is 0 (§11.2).
remainder = (a : Int, b : Int) -> Int { to_text
The digits of value in radix (2 to 36), with - when it is
negative; digits above 9 are capital letters.
to_text = (value : Int, radix : Int) -> String {