Clever. For those of us unfamiliar with bitwise ops, here's how this works:
The bitwise and op (&) works on bits like this:
dig1 dig2 Result
000
010
100
111
An even number's binary representation always ends with 0 (ie 12 = 1100)
while an odd ends with 1 (ie 13
You all are a bunch of un-optimizing novices. Just do some bit banging.
i.e.
if(1 & number){
echo "$number is odd";
}else{
echo "$number is even";
}
-Original Message-
From: Brandon Orther [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 05, 2001 12:18 PM
To: PHP User Gro
2 matches
Mail list logo