note 63854 deleted from language.functions by bjori

From: Date: Sun, 02 Apr 2006 14:49:58 +0000
Subject: note 63854 deleted from language.functions by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107168@lists.php.net to get a copy of this message
Note Submitter: Reason: bad code ---- PHP apparently doesn't have anything equivalent to the C functions odd() and even() for testing the nature of integers. I can't think of a cheaper way to implement them than these (2 one-bit shifts and a compare): function even($v) { return ((($v>>1)<<1)==$v) ; } function odd($v) { return ((($v>>1)<<1)<$v) ; } (I note that there's also no obviously correct place to offer functions like this. If there were a section called 'Integer Functions' that would be a logical place, but there isn't. Since this is not an isolated problem, perhaps whoever's maintaining this online documentation could add a section called 'Contributed Functions That Don't Fit Anywhere Else' :-) )

« previous php.notes (#107168) next »