ID:175615
 
Hi again. I need a way for a game to tell me if a number is even or odd when asked the question. I think it may have something to do with dividing it by 2 and seeing if it's a whole number, but I can't do that, either.
The % operator will return the remainder of division. If a number is even, it will be evenly divisible by two. So...

mob/verb/even_odd(num as num)
if(num % 2 == 0)
world << "[num] is even."
else
world << "Hey, [num] is odd!"

CoWdUdE7 wrote:
Hi again. I need a way for a game to tell me if a number is even or odd when asked the question. I think it may have something to do with dividing it by 2 and seeing if it's a whole number, but I can't do that, either.

Another way of telling odd from even

proc/IsOdd(n as num)
return n & 1


or if your going for effeciency you could make it a macro
#define IS_ODD(N)   ((N) & 1)