mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +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 = {}
|
||||||
|
|
||||||
ESX.Math.Round = function(value, numDecimalPlaces)
|
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
|
end
|
||||||
|
|
||||||
-- credit http://richard.warburton.it
|
-- credit http://richard.warburton.it
|
||||||
|
|||||||
Reference in New Issue
Block a user