PDA

View Full Version : Detecting odd numbers?



REEFˇ
August 29th, 2006, 05:10 PM
Is there a script to detect if var a is odd?

I'm trying to do this:


var a:Number = 3;
if(a is odd) {
trace("a is odd");
else {
trace("a is even");
}And yes var a will always be a whole number, never a decimal.

silentweed
August 29th, 2006, 05:25 PM
var a:Number = 3;
if(a%2 != 0) {
trace("a is odd");
else {
trace("a is even");
}

REEFˇ
August 29th, 2006, 05:33 PM
Thanks a ton, that works perfect.

randomagain
February 8th, 2007, 05:51 PM
woot good