Actionscript:
-
// from http://www.bit-101.com/blog/?p=729
-
var number:Number = 10.5;
-
-
// for numbers
-
var isEven:Boolean = (number % 2) == 0;
-
trace(isEven);
-
-
// for ints
-
var integer:int = 10;
-
isEven = (integer & 1) == 0;
-
trace(isEven);
This is a classic that I've seen all over the place online... found myself needing it today and figured I should post it. It just an easy way to determine if a number is odd or even... I remember originally reading it over at Bit-101.com a few years back...
Two posts today because I think I missed a post recently...