ItsMods

Full Version: Number Multiples
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
uhm
lol
in my code i wrote an else...
but ive forgot it here
(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