note 15810 added to language.operators.bitwise
| From: | frk at dagbladet dot no | Date: | Wed, 03 Oct 2001 19:39:40 +0000 |
| Subject: | note 15810 added to language.operators.bitwise | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18531@lists.php.net to get a copy of this message | ||
Here are two functions to count number of bits who are set in a variable.
function bit_count($num) {
return strlen(str_replace('0','',decbin($num)));
}
function bit_count($value){
return ((count(split('1',decbin($value))))-1);
}
--
http://www.php.net/manual/en/language.operators.bitwise.php
http://master.php.net/manage/user-notes.php?action=edit+15810
http://master.php.net/manage/user-notes.php?action=delete+15810
http://master.php.net/manage/user-notes.php?action=reject+15810