ID:175615
Mar 28 2003, 8:26 am
|
|
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.
|
Mar 28 2003, 8:30 am
|
|
The % operator will return the remainder of division. If a number is even, it will be evenly divisible by two. So...
|
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) or if your going for effeciency you could make it a macro
#define IS_ODD(N) ((N) & 1)
|