mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 23:01:30 +00:00
9b33a3e6ca
Co-Authored-By: hugocabral <hugocabral@users.noreply.github.com>
25 lines
614 B
Lua
25 lines
614 B
Lua
ESX.Math = {}
|
|
|
|
ESX.Math.Round = function(value, numDecimalPlaces)
|
|
if numDecimalPlaces then
|
|
local power = 10^numDecimalPlaces
|
|
return math.floor((value * power) + 0.5) / (power)
|
|
else
|
|
return math.floor(value + 0.5)
|
|
end
|
|
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
|
|
|
|
ESX.Math.Trim = function(value)
|
|
if value then
|
|
return (string.gsub(value, "^%s*(.-)%s*$", "%1"))
|
|
else
|
|
return nil
|
|
end
|
|
end |