A big-number library for Roblox incremental games. Stores values as a normalized mantissa/exponent pair so calculations stay accurate well beyond what a regular number can represent.
Add to your wally.toml:
[dependencies]
QNum = "notiku/qnum@0.2.1"Then run:
wally installlocalQNum=require(Path.To.QNum)
localgold=QNum.fromNumber(1500)
localreward=QNum.fromString("2.5e9")
localtotal=gold+rewardprint(total) --> 2.50Bprint(total:Format()) --> 2.50Bprint(QNum.toScientific(total)) --> 2.50e9| Function | Description |
|---|---|
QNum.new(mantissa?, exponent?) | Builds a QNum from a mantissa and exponent. |
QNum.fromNumber(n) | Builds a QNum from a regular Roblox number. |
QNum.fromString(s) | Parses plain, scientific (1.5e9), or suffix (2.5B) notation. |
add, sub, mul, div, pow are available as static functions (QNum.add(a, b)), as instance methods (a:Add(b)), and via metamethods (a + b, a - b, a * b, a / b, a ^ 2).
eq, gt, lt, gte, lte — also wired up to ==, <, <=.
| Function | Example |
|---|---|
QNum.format(value, decimals?) | 1.25M |
QNum.toScientific(value, decimals?) | 1.25e6 |
QNum.withSuffix(value, decimals?) | 1.25M |
QNum.getSuffix(index) | "k", "M", "B", "T", … |
QNum.getSuffixIndex(suffix) | Inverse of getSuffix. |
tostring(value) is equivalent to QNum.format(value).
QNum.clone(value)QNum.normalize(value)QNum.toNumber(value)— converts back to a regular number (may overflow for huge values)QNum.zero,QNum.one
See LICENSE.