04-20-2011, 21:08
Pages: 1 2
04-25-2011, 09:39
(04-20-2011, 01:27)AZUMIKKEL Wrote: [ -> ](04-20-2011, 01:15)master131 Wrote: [ -> ]% is the modulus operator. It gets the remainder when you divide a number by the other.
5 % 2 = 1 (5 divided by 2 has a remainder of 1)
So it rounds the number down and calculates the amount it rounded down?
So 8/3 would be 2,(2/3). 0,(2/3)*3 = 2 ?
I wonder what this would ever be handy for.
Maybe to check if a number is even or odd?
Code:
if(someNumber % 2 == 0) //If number is even (can be divided by 2 with no remainder)
//Do crap here
else //Number is odd
//Do crap here
Pages: 1 2