From 9b33a3e6ca09db51199b2440982e9103eab6f35a Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Fri, 3 Jan 2020 19:10:25 +0100 Subject: [PATCH] Fix math round function again Co-Authored-By: hugocabral --- common/modules/math.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/modules/math.lua b/common/modules/math.lua index 99a87631..947ccd78 100644 --- a/common/modules/math.lua +++ b/common/modules/math.lua @@ -1,8 +1,12 @@ ESX.Math = {} ESX.Math.Round = function(value, numDecimalPlaces) - local mult = 10^(numDecimalPlaces or 0) - return math.floor(value * mult + 0.5) / mult + 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