I'm trying to make an AND operation between 2 Bigints and then to count the number of bits 1 on binary representation.
Example :
$a and $b are bigints resulting of a MySql query.
$result = countones($a & $b);
with :
function countones($n){
  $c =0;
  while($n){
    $c += $n&1;
    $n = $n>>1;
  }
  return $c;
}
With Ints no problem. I've tried to use gmp functions but my attemps failed... I must be missing something...
 
    