Snippet Name: Easily detect Odd/Even numbers
Description: This is a simple way to tell whether a given number is odd or even. It works via a bitwise compare. You really only need one of these functions, since if a number isn't odd, it's even.
Also see: » Easily detect Odd/Even numbers
» Dates: Oddball Stuff
» Set cookie even after HTML output
» Prevent the 'enter' key from submiting...
» Is Number Even?
» Prevent framing a page
Comment: (none)
Language: PHP
Highlight Mode: PHP
Last Modified: August 01st, 2009
|
FUNCTION odd($var) {
RETURN($var & 1);
}
FUNCTION even($var) {
RETURN(!($var & 1));
} |