ok so I was separating a variable that was equal to 5.2
I did
var %= 1
this is how I separated the fraction
problem is it came out as 0.1999999…
which was bad because I needing to do multiplication afterwards
so I just tested it the multiplication to see if I had no floating point errors by making var = 0.2 without the modulo as a test
the multiplication worked but then it started doing floating points as well
is there a good way to use modulo or multiply two numbers without getting a floating point error?
Floating-point errors are nearly arbitrary and seems to be nearly unpredictable. It adjusts itself and rounds to the closest valid value but is unable to precisely fill the exact value. There are mitigation methods(but it doesn’t quite remove everything!).
The only way to fix float errors is to add code for it yourself. For example, if you know your numbers shouldn’t have over 2 decimals, use this:
local n = 1.111
n = math.round(n*100)/100
But besides that, there’s not much you can do. Float errors are mostly benign and present an issue only when displaying numbers or in very precise placements.