Bignum
A whole number of up to 400 decimal digits; any result past that raises. Values are immutable: every method returns a new bignum. Equal values are the same userdata, so == and table keys work by value, and typeof(x) is "bignum".
Use the methods for arithmetic and ordering: the type checker rejects +, < and the other operators on a Bignum. The methods take a plain number or text on the other side. tostring(x) and x:tostring() both give the plain digits.
At most 100000 distinct values may be alive at once; values nothing references are reclaimed.
Methods
self * by. A fractional by is allowed; the product truncates toward zero. a fractional number truncates toward zero
self / by, floored like //. by may be fractional; zero raises. floors, like //
The remainder of the floored division: it takes the divisor's sign, like %. Both sides must be whole; a zero divisor raises. takes the divisor's sign, like %
self ^ exponent. The exponent is a whole number of zero or more; anything else raises.
Compares with other: -1 if smaller, 0 if equal, 1 if larger. other may be fractional. -1, 0 or 1
bignum:sign() -> number#-1, 0 or 1.
bignum:iszero() -> boolean#Whether the value is 0.
bignum:digits() -> number#How many decimal digits the absolute value has; 0 has one.
bignum:tostring() -> string#The plain decimal digits, with a leading - when negative: "1234567".
bignum:tonumber() -> number#The value as a Luau number. loses precision past 2^53
bignum:format(decimals: number?) -> string#Compact text: "1.2M", "3.4Qa". Below 1000 it is the grouped digits. Extra decimals are cut, not rounded, and trailing zeros dropped. Suffixes run k, M, B, T, Qa, Qi, Sx, Sp, Oc, No, De, Ud, Dd, Td, Qd, Qn, Sd, Spd, Od, Nd, Vg. "1.2M"; decimals 0..3, default 1
bignum:grouped() -> string#The digits with comma thousands separators. "1,234,567"