mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
Fixed round function not properly working in some locales, closes #258
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
ESX.Math = {}
|
||||
|
||||
ESX.Math.Round = function(value, numDecimalPlaces)
|
||||
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", value))
|
||||
local mult = 10^(numDecimalPlaces or 0)
|
||||
return math.floor(value * mult + 0.5) / mult
|
||||
end
|
||||
|
||||
-- credit http://richard.warburton.it
|
||||
|
||||
Reference in New Issue
Block a user