note 63854 added to language.functions

From: Date: Sun, 02 Apr 2006 08:59:26 +0000
Subject: note 63854 added to language.functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-107152@lists.php.net to get a copy of this message
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' :-) ) ---- Server IP: 216.194.113.175 Probable Submitter: 151.203.163.137 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.functions.php Edit -- http://master.php.net/note/edit/63854 Del: integrated -- http://master.php.net/note/delete/63854/integrated Del: useless -- http://master.php.net/note/delete/63854/useless Del: bad code -- http://master.php.net/note/delete/63854/bad+code Del: spam -- http://master.php.net/note/delete/63854/spam Del: non-english -- http://master.php.net/note/delete/63854/non-english Del: in docs -- http://master.php.net/note/delete/63854/in+docs Del: other reasons-- http://master.php.net/note/delete/63854 Reject -- http://master.php.net/note/reject/63854 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107152) next »