KBigInt
An arbitrary-precision integer: what BigInt values are made of.
Upstream uses java.math.BigInteger, which common Kotlin has no equal of, so this is the port's own (D-5). Sign and magnitude, with the magnitude a little-endian IntArray of base 2^32 limbs and no trailing zero limbs, so a value has exactly one representation and equality is a plain array comparison.
The bitwise operations follow the JavaScript rule: two's complement over an infinitely long bit string, so -1n and 3n is 3n and not(5n) is -6n. shiftRight floors, matching >>.
It deliberately does NOT extend Number, even though upstream's BigInteger does: on Kotlin/JS Number is the JS primitive number type, so a class extending it fails is Number and throws on as Number. The runtime tells a bigint apart with is KBigInt instead (D-54).
Constructors
Functions
Compares against a finite d without losing anything to rounding.
The value as an Int, or an error when it does not fit.
The value as a Long, or an error when it does not fit.
Arithmetic, so it floors: -5 shr 1 is -3, not -2.