Module:NumberFormater: Difference between revisions
From IdleOn MMO Wiki
Kiokurashi (talk | contribs) mNo edit summary |
Kiokurashi (talk | contribs) mNo edit summary |
||
Line 35: | Line 35: | ||
local n = tonumber(arg:sub(1, 4)) / 100 | local n = tonumber(arg:sub(1, 4)) / 100 | ||
return string.format("%s%s", n, UNIT_EXPONENTS[unit]) | return string.format("%s %s", n, UNIT_EXPONENTS[unit]) | ||
end | end | ||
return p | return p |
Revision as of 01:26, 12 March 2024
Abbreviation | Name | Value | Equivalent |
---|---|---|---|
K | Thousand or Kilodillion | 10^3 | |
M | Million | 10^6 | |
B | Billion | 10^9 | |
T | Trillion | 10^12 | |
Qa | Quadrillion | 10^15 | |
Qi | Quintillion | 10^18 | |
Sx | Sextillion | 10^21 | |
Sp | Septillion | 10^24 | |
O | Octillion | 10^27 | |
No | Nonillion | 10^30 | |
D | Decillion | 10^33 | |
Udc | Undecillion | 10^36 | |
Dd | Duodecillion | 10^39 | |
Tdc | Tredecillion | 10^42 | |
Qt | Quattuordecillion | 10^45 | |
Qd | Quindecillion | 10^48 | |
Sd | Sexdecillion | 10^51 | |
St | Septendecillion | 10^54 | |
Od | Octodecillion | 10^57 | |
Nm | Novemdecillion | 10^60 | |
Vg | Vigintillion | 10^63 | |
Uvg | Unvigintillion | 10^66 | |
Dvg | Duovigintillion | 10^69 | |
Tvg | Tresvigintillion or Trevigintillion | 10^72 | |
Qav | Quattuorvigintillion | 10^75 | |
Qvg | Quinvigintillion | 10^78 | |
Svg | Sexvigintillion or Sesvigintillion | 10^81 | |
Spv | Septemvigintillion or Septenvigintillion | 10^84 | |
Ovg | Octovigintillion | 10^87 | |
Nvg | Novemvigintillion or Novenvigintillion | 10^90 | |
Tg | Trigintillion | 10^93 | |
Ut | Untrigintillion | 10^96 | |
Dt | Duotrigintillion | 10^99 | |
Reamining will follow e# notation. |
* Sources from an external Github site.
local p = {}
local UNIT_EXPONENTS = {
'K',
'M',
'B',
'T',
'Q',
'QQ',
'S',
'SP',
'O',
'N',
'D'
}
function p.main(frame)
local numstr = frame.args[1]
if numstr == "Lots" then
return numstr
end
if tonumber(numstr) == nil then
return "<BAD NUMBER>"
end
return formatnumber(numstr)
end
function formatnumber(arg)
-- how many digts are after the first digit divided by 3.
local unit = math.floor((arg:len() - 1) / 3)
if unit == 0 then
return arg
end
-- Get float of first 4 chracters.
local n = tonumber(arg:sub(1, 4)) / 100
return string.format("%s %s", n, UNIT_EXPONENTS[unit])
end
return p