Search code examples
phpc++intunsigned

Bitwise and unsigned int operations in PHP


I'm trying to convert my C++ code to PHP and I'm stuck, my source codes uses unsigned integers (32bit) and many bitwise operations like rotations, xor, shifting, I'm trying my best to make it work, I'm cutting integers to 32bit

$i = $i & 0xFFFFFFFF;

but still I'm having a lot of troubles (my guess it has something to do with multiplication/division) this time.

Are there any libraries for PHP that handles operations on 32bit unsigned integers, any other ideas are also welcome :) Thank you :)


Solution

  • Please take a look of how Java programmers handler unsigned int's

    http://www.javamex.com/java_equivalents/unsigned.shtml

    I guess that's the only way of doing it...