Bitwise and unsigned int operations in PHP

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

$ i = $ i and 0xFFFFFFFF;

but still I have a lot of problems (in my opinion, this is due to multiplication / division).

Are there libraries for PHP that handle operations with 32-bit unsigned integers, any other ideas are also welcome :) Thanks :)

+3
source share
3 answers

Please see how the unsigned Java programmer handler int

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

, ...

+1

I had similar problems a few years ago. It turned out that the problem was in the operating system, which was 32-bit. Switching to 64-bit OS solved the problems for me.

0
source

Source: https://habr.com/ru/post/1786036/


All Articles