fork download
  1. <?php
  2.  
  3. echo "Bits in an int: ".(count_bits(PHP_INT_MAX) + 1);
  4.  
  5. // Counts how many bits are needed to represent $value
  6. function count_bits($value) {
  7. for($count = 0; $value != 0; $value >>= 1) {
  8. ++$count;
  9. }
  10. return $count;
  11. }
  12.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Bits in an int: 32