Hello, I’m trying to make a modulus function but adjust the values a little.
I know well what modulus is and what it does but I can’t find the equation it uses.
I found out that its something like this: a - b * math.floor(a / b) but this example is from other coding languages.
I don’t know what equation luau uses because it has some differences when using negative numbers with modulus to other languages.
I ran this code and a%b == a - b * math.floor(a / b) was true in all a and b combinations (except when b = 0, both sides of the equation were nan (undefined) and nan == nan is false for some reason):
print("START")
for a = -100, 100 do
for b = -100, 100 do
if a%b ~= a - b * math.floor(a / b) then
warn(a, b)
print(a%b)
print(a - b * math.floor(a / b))
end
end
task.wait()
end
print("FINISH")