programming-examples/php/_Basics/PHP program to reverse the bits of an integer (32 bits unsigned)..php
2019-11-15 12:59:38 +01:00

15 lines
266 B
PHP

<?php
function reverse_integer($n)
{
$result = 0;
for($i= 0; $i<32; $i++)
{
$result <<= 1;
$result|= ($n & 1);
$n >>= 1;
}
return $result;
}
print_r(reverse_integer(1234)."\n");
?>