Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why does this script turn to 1e.+K+ after when it hits 100T? ( Cash Suffix Script )

Asked by 5 years ago
Edited 5 years ago
01function module:ConvertShort(Filter_Num)
02    local x = tostring(Filter_Num)
03    if #x>=13 then
04        local important = (#x-12)
05        return x:sub(0,(important)).."."..(x:sub(#x-11,(#x-11))).."T+"
06    elseif #x>=10 then
07        local important = (#x-9)
08        return x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B+"
09    elseif #x>= 7 then
10        local important = (#x-6)
11        return x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M+"
12    elseif #x>=4 then
13        return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
14    else
15        return Filter_Num
16    end
17end
18 
19return module

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
5 years ago

because numbers are shown using exponentation (e, not euler) after a set number is passed. you shouldn't use such a brute-force method for something like that, but i'll support it anyway.

you should probably divide by the waypoint (ex. 105 trillion by 100 trillion) in order to get it's base value, then concatenate the quotient with the "T", "K", "B", etc..

or.. you can just find a different way to code it! it's all up to you.

postscript: e is the shorthand for 1x10^n, n being the amount of zeroes.
Ad

Answer this question