Everybody knows what +, -, * and / do but what does % do…
There’s almost NO documentation anywhere about what it does.
It really seems like i should know this since I’ve been coding for a while now but i never once used %… Does anybody know??
And if somebody does and has used it, what’s it good for?
It’s called the modulus operator. X%Y returns the remainder of x divided by y. I commonly use it to check if numbers are even or odd. X % 2 returns 0 if X is even and 1 if X is odd.