This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Hypot function for Lua. Better semantics than (x^2+y^2)^.5 as this accounts for overflow and underflow. | |
-- For: | |
-- - Lua 3.1 | |
-- - Lua 3.2 | |
-- - Lua 4.0 | |
-- - Lua 4.1 | |
-- - Lua 5.0 | |
-- - Lua 5.1 | |
-- - Lua 5.2 | |
-- - Lua 5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local suffix={'K','M','G','T','P','E','Z','Y'};function FormatInteger(n)return tostring(math.floor(n)):reverse():gsub('%d%d%d','%1 '):gsub(' $',''):reverse()end;function FormatCompactInteger(n)return((((n<1000)and(n)or math.floor(n/(1000^math.floor(math.log10(n)/3))*((math.log10(n)%3<1)and 10 or 1))/((math.log10(n)%3<1)and 10 or 1))..(suffix[math.floor(math.log10(n)/3)]or'')):gsub('[.]',','))end; |