Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Commit

Permalink
bug: Fixed problem with number format
Browse files Browse the repository at this point in the history
Previously, big numbers were formatted into a wrong type. For example
 1000000000 => 10B (which should be 1B)

With this commit, those problems are fixed

Additionally a new rule for quadrillions (P) added
  • Loading branch information
Seniru committed Jan 8, 2020
1 parent c2f7bb0 commit 276dbe0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,18 @@ function float(n, digits)
end

function formatNumber(n)
if n >= 1000000000000 then
return float(math.floor(n / 100000000000),1) .. "T"
elseif n >= 1000000000 then
return float(math.floor(n / 100000000),1) .. "B"
elseif n >= 1000000 then
return float(math.floor(n / 100000),1) .. "M"
elseif n >= 10000 then
return float(math.floor(n / 1000),1) .. "K"
if n >= 10e14 then
return float(math.floor(n / 10e14),1) .. "P"
elseif n >= 10e11 then
return float(math.floor(n / 10e11),1) .. "T"
elseif n >= 10e8 then
return float(math.floor(n / 10e8),1) .. "B"
elseif n >= 10e5 then
return float(math.floor(n / 10e5),1) .. "M"
elseif n >= 10e3 then
return float(math.floor(n / 10e2),1) .. "K"
end
return float(n,1)
return float(n, 1)
end

function upper(str)
Expand Down

0 comments on commit 276dbe0

Please sign in to comment.