note 98407 added to function.gmp-testbit
| From: | tbrendstrup at osu1 dot php dot net | Date: | Mon, 14 Jun 2010 02:40:45 +0000 |
| Subject: | note 98407 added to function.gmp-testbit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170106@lists.php.net to get a copy of this message | ||
If gmp_testbit isn't available on you platform (but other gmp functions are) you can use this
substitution:
<?php
gmp_cmp($val, gmp_clrbit($val, $i)) != 0
?>
Example:
<?php
// counts the number of bits set
function GetFreeCount($part)
{
$count = 0;
$val = gmp_init($part);
for($i=0;$i<64;$i++)
{
// equivalent of gmp_testbit($val, $i)
if(gmp_cmp($val, gmp_clrbit($val, $i)) != 0)
{
$count++;
}
}
return $count;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 93.160.184.10
----
Manual Page -- http://www.php.net/manual/en/function.gmp-testbit.php
Edit -- https://master.php.net/note/edit/98407
Del: integrated -- https://master.php.net/note/delete/98407/integrated
Del: useless -- https://master.php.net/note/delete/98407/useless
Del: bad code -- https://master.php.net/note/delete/98407/bad+code
Del: spam -- https://master.php.net/note/delete/98407/spam
Del: non-english -- https://master.php.net/note/delete/98407/non-english
Del: in docs -- https://master.php.net/note/delete/98407/in+docs
Del: other reasons-- https://master.php.net/note/delete/98407
Reject -- https://master.php.net/note/reject/98407
Search -- https://master.php.net/manage/user-notes.php