Save-Point

Full Version: How to check if the value of a number is an even or odd number?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Heya, I was wondering if there was a way I could check if the value of a number is even or odd numbered through scripting. Is there? If so, how do I do it? :o
There has gotta be a simple MACL def to handle odd/even checking. Something like:
if my_test_value.is_a?(odd_value) or something
Code:
if number%2==0
  #even
else
  #odd
end
*Smacks forehead*
The % Remainder symbol. I totally forgot. Yep. That'll do it.
pwnt.
(I didn't see that coming, thought it was a trick question :l)
Oh man, thanks Charlie. :D