How can you convert a integer into it's bits representation?
For example number 9 representation in bits is: 10011
For example to convert a bit sequence into it's int representation you can do this:
$bits_sq = array(1,0,0,1,1);
function convert_bits_to_int($bits_sq){
$sum = 0;
for($i=0; $i < count($bits_sq); $i++){
$sum = $sum + $bits_sq[$i] * pow(-2, $i);
}
print $sum; // equals to 9
}
But I want the other way around.
Edit: DO NOT MISTAKE BITS WITH BINARY, THIS IS NOT THE DUPLICATE NEITHER HAS THE ANSWER IN THE ABOVE THREAD