mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Added ESX.Math.*
This commit is contained in:
@@ -59,7 +59,6 @@ ESX.DumpTable = function(table, nb)
|
||||
end
|
||||
|
||||
|
||||
ESX.Round = function(value)
|
||||
return value >= 0 and math.floor(value + 0.5) or math.ceil(value - 0.5)
|
||||
ESX.Round = function(value, numDecimalPlaces)
|
||||
return ESX.Math.Round(value, numDecimalPlaces)
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
ESX.Math = {}
|
||||
|
||||
ESX.Math.Round = function(value, numDecimalPlaces)
|
||||
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", value))
|
||||
end
|
||||
|
||||
-- credit http://richard.warburton.it
|
||||
ESX.Math.GroupDigits = function(value)
|
||||
local left,num,right = string.match(value,'^([^%d]*%d)(%d*)(.-)$')
|
||||
|
||||
return left..(num:reverse():gsub('(%d%d%d)','%1' .. _U('locale_digit_grouping_symbol')):reverse())..right
|
||||
end
|
||||
Reference in New Issue
Block a user