Re: Anyway of knowing whether a integer is odd or even

From: Date: Tue, 09 Oct 2001 17:09:31 +0000
Subject: Re: Anyway of knowing whether a integer is odd or even
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-70518@lists.php.net to get a copy of this message
On Tue, 09 Oct 2001 13:07:17 -0400, you wrote: >It is generally faster (but harder to read) >to use bitwise operators... > >if ($theInt & 1) > print "$theInt is odd"; >else > print "$theInt is even"; > >This is usually the case for most languages, like C or C++ or what have >you. It's probably the same in PHP, since the & operator doesn't need to >worry about returning the remainder, just the bits that are set in both >$theInt and 1. I'm sure I don't want to get into this, but... If speed is that important, why would you use a scripting language? djo

« previous php.general (#70518) next »