note 98407 deleted from function.gmp-testbit by danbrown

From: Date: Mon, 14 Jun 2010 12:34:49 +0000
Subject: note 98407 deleted from function.gmp-testbit by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170112@lists.php.net to get a copy of this message
Note Submitter: tbrendstrup ---- 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; } ?>

« previous php.notes (#170112) next »