Hello developers, so im trying to subtract 0.025 from 0.3 and whenever i do, the value 0.3 turns into 0.27499999999999997. Can anyone help me please? this is strange.

Update: so no matter what value i subtract, it alwaus ends up removing an extra 0.0000000000000003

I tried removing 0.02 from 0.3 and the final value was 0.27999999999999997

Update 2: the actual value is what the value should be. But when applied to a text or printed its for some reason 0.27999999999999997

you should use `math.round()`

whenever you get the value.

This’s floating point issue. Bc PC can’t normally show you numbers like 1/3, and it will show you 0.3333333333333 instead. But when you will multiply it back you expect to see 1, but not 0.9999999999999 So use rounding to solve this.

Im not too familiar with math.round. Could you show me a soloution with it?

Personally I use this function to round numbers `FOR TEXT!!!`

```
local function RoundText(Number, Snap):string
local Decimal = 0
if Snap >= 1 then
while Snap >= 1 do
Snap = Snap / 10
Decimal = Decimal + 1
end
elseif Snap < 1 then
while Snap < 1 do
Snap = Snap * 10
Decimal = Decimal - 1
end
end
local Result = {}
local Line = tostring(Number)
while string.match(Line, ".", #Result + 1) ~= "." and string.match(Line, ".", #Result + 1) ~= nil do
--print("Inserting " .. string.match(Line, ".", #Result + 1))
table.insert(Result, string.match(Line, ".", #Result + 1))
end
if Decimal < 0 then
table.insert(Result, "\.")
end
while Decimal < 0 do
--print("Inserting " .. string.match(Line, ".", #Result + 1))
table.insert(Result, (string.match(Line, ".", #Result + 1) or 0))
Decimal = Decimal + 1
end
local Round
Line = string.sub(Line, #Result + 1, #Result + 1)
if string.match(Line, "[56789]") ~= nil then
local i = #Result
while Result[i] == "9" or Result[i] == "." do
if Result[i] == "." then i = i - 1 continue end
Result[i] = "0"
i = i - 1
end
Result[i] = if Result[i] == "0" then "1" elseif Result[i] == "1" then "2" elseif Result[i] == "2" then "3"
elseif Result[i] == "3" then "4" elseif Result[i] == "4" then "5" elseif Result[i] == "5" then "6"
elseif Result[i] == "6" then "7" elseif Result[i] == "7" then "8" else "9"
end
local ReturnText = ""
for i = 1, #Result, 1 do
ReturnText = ReturnText .. Result[i]
end
return ReturnText
end
```

I’m not use built-in round function, bc it round to first integer, while I need decimal. When I tried multiply number by 10, 100… and then divide back, it still was 0.99999999999994126418…