# What are these bitwise operations doing? [closed]

I found a snippet of code on the PHP manual which packs 64 bit integers. APparently this is necessary because pack() always treats numbers as 32 bit integers even on 64 bit architectures.

I don't understand what is happening with the use of $left and$right as well has notation like >>32. Searching that didn't find anything useful. Can anyone explain what is happening in this script?

<?php
$big = 5000000000;$left = 0xffffffff00000000;
$right = 0x00000000ffffffff;$l = ($big &$left) >>32;
$r =$big & $right;$good = pack('NN', $l,$r);

-
Unfortunately, helping you understand code is off topic on Code Review, as explained in the faq. –  codesparkle Feb 26 '13 at 10:32

## closed as off topic by Quentin Pradet, codesparkleFeb 26 '13 at 10:32

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

It's taking a 64 bit number

$big = 5000000000;  Using masks for the top 32 bits $left = 0xffffffff00000000;


and bottom 32 bits

$right = 0x00000000ffffffff;  Selecting the top 32 bits and shifting the value to a 32 bit value $l = ($big &$left) >>32;


Selecting the bottom 32 bits

$r =$big & $right;  and finally packs the 2 32 bit values into 64 bits $good = pack('NN', $l,$r);

-