PHP 8.5.0 Beta 1 available for testing

Voting

: six minus zero?
(Example: nine)

The Note You're Voting On

forlamp at msn dot com
17 years ago
two's complement logical operation for 32-bit.

$x must be (int) when passing it to this function to work properly.

function comp2($x) // 32bit bitwise complement
{
$mask = 0x80000000;

if ($x < 0)
{
$x &= 0x7FFFFFFF;
$x = ~$x;

return $x ^ $mask;
}
else
{
$x = $x ^ 0x7FFFFFFF;

return $x | $mask;
}
}

<< Back to user notes page

To Top