Number getting high decimal places

FIXED

sorry if the title is confusing, but basically my numbervalue keeps going to values like 1.5000000000001 and such, and it’s really annoying. what im doing is im just adding 0.01 points every 1/100 of a second, i don’t know why this happens

as you can see this is annoying as heck

local currentValue = baseValue / 100 -- 0.01
			for _, multi in pairs(gains[statName]) do -- theres no multis
				currentValue *= multi
			end
			currencies[statName].Value = zephyrMath.AdvRound(currencies[statName].Value + currentValue, 0.01) -- my rounding function (didnt work without it too)
function funcs.AdvRound(value : number, increment : number, bias : number)
	-- For example, pretend value = 260, increment = 50, and bias = 0 --
	
	local cycles = value / increment -- Ex. 260 / 50 = 5.1
	
	if bias == 0 then -- Round Down
		cycles = math.floor(cycles) -- Ex. 5.1 >> 5
	elseif bias == 1 then -- Round Up
		cycles = math.ceil(cycles)
	else -- Round Normally
		cycles = math.round(cycles)
	end
	
	-- Get Result
	local result = cycles * increment -- Ex: 50 x 5 = 250 (250 is the closest multiple of increment 50 to 260)
	
	return result
end

im using number values to display decimals such as 1.52, but i do not want 1.00000000000001 being shown to my players

This is a problem in all computer programming when working with floats. best course of action is to round the number to the decimal place you want it at.

This happens due to floating point precision, you can google about it if you like.
As for the solution, you can use string.format("%.2f", value) to get the number rounded to 2 decimal places (as a string).

(In that function call, “%” means that you are using the value provided as the next argument, and “.2f” means it is a number rounded to 2 decimal places).

dang i usually get responses after 3 hours, this helped alot ty

i tried rounding the number with my function AdvRound to the nearest .01, guess i had to do it on the string side though, ty tho

ah ok, dang i should look into string.format soon it seems useful