what does the percentage (%) symbol mean/do in lua?

Hey guys can you help me please,

what does the percentage (%) symbol mean/do in lua???

In Lua, % is the ‘modulo’ operator. It gives you the REMAINDER from a division.

E.g.

12 % 6 = 0 (no remainder)

10 % 6 = 4 (6 goes into 10 once, with 4 leftover)

100 % 30 = 10

20 % 9 = 2

Exactly. One minor hiccup that I always run into is that the result of e.g. modulo 5 go from 0 to 4, and not from 1 to 5. The fix is of course super-easy, but I always seem to forget!

Appreciate it guys thank you

Actually @thomas6, that’s by design.   6%6 = 0 because there is no remainder.  You cannot get a 6 back because the remainder will always be some number less than what you’re modding by.

In Lua, % is the ‘modulo’ operator. It gives you the REMAINDER from a division.

E.g.

12 % 6 = 0 (no remainder)

10 % 6 = 4 (6 goes into 10 once, with 4 leftover)

100 % 30 = 10

20 % 9 = 2

Exactly. One minor hiccup that I always run into is that the result of e.g. modulo 5 go from 0 to 4, and not from 1 to 5. The fix is of course super-easy, but I always seem to forget!

Appreciate it guys thank you

Actually @thomas6, that’s by design.   6%6 = 0 because there is no remainder.  You cannot get a 6 back because the remainder will always be some number less than what you’re modding by.