note 35853 added to function.bcmod
| From: | mackaye at iprimus dot com dot au | Date: | Wed, 17 Sep 2003 02:28:56 +0000 |
| Subject: | note 35853 added to function.bcmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56611@lists.php.net to get a copy of this message | ||
It is correct to use $i%2 to get even and odd program control
HOWEVER
using bit level operators is better, faster and more effecient
so
TO get odd and even $num&1 is much better
To NULL any element $element^$element is also much better
For New comers
these functions are based on the binary representation of variables in memory.
It so happens that an even number always has a
0 on the end, and an odd number always has a 1 on
the end
so
1010101 &
0000001
is true
----
Manual Page -- http://www.php.net/manual/en/function.bcmod.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35853
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35853&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35853&report=yes