Search the docs

Find a guide, global, type or member

GlobalLibraries

bignum

Whole numbers of up to 400 digits, for currencies that outgrow a Luau number.

Functions

bignum.new(value: BigLike) -> Bignum#

Makes a bignum from a bignum, a whole number or text. Raises on text it cannot read, on a fractional or non-finite number, and past 400 digits. raises on text it cannot read or past 400 digits

bignum.parse(text: string) -> Bignum#

Reads text such as "1.5M", "2K", "-3B", "1.2e24", "1,234" or "1_000". Spaces around it, commas and underscores are ignored; a fraction is cut toward zero ("1.99" is 1). Suffixes are those format writes, plus K. Returns nil for anything unreadable, past 400 digits, or not a string.

bignum.format(value: BigLike, decimals: number?) -> string#

bignum.new(value):format(decimals).

bignum.tostring(value: BigLike) -> string#

The plain decimal digits of value.

bignum.tonumber(value: BigLike) -> number#

value as a Luau number; loses precision past 2^53.

bignum.cmp(a: BigLike, b: BigLike) -> number#

-1, 0 or 1 as a is smaller than, equal to or larger than b.

bignum.min(a: BigLike, b: BigLike) -> Bignum#

The smaller of the two, as a bignum.

bignum.max(a: BigLike, b: BigLike) -> Bignum#

The larger of the two, as a bignum.