Tuesday, May 03, 2005

Performance tips:

To test for even/odd number, instead of using %, use bitwise & based on the property that the last bit of an even number is always 0 and the last bit of odd number is always 1.
e.g.

var even:Boolean = (number % 2 == 0);

var evenBetter:Boolean = (number & 0x1 == 0);

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home