32-bit unsigned int php

Does anyone know a class / library / etc. which can simulate unsigned 32-bit integers on a 32-bit platform in PHP? I am porting C lib to PHP and uses a lot of integers that are more than the maximum for a 32 bit signed int.

+3
source share
3 answers

Try the BC Math Library , which "supports numbers of any size and precision represented as strings."

Good luck

+2
source

Why can't you write

  modulo(a+b,2^32)

PHP a, b - , " ", , , ,...? , , add_unsigned, .

0

Do you really need this? php converts to float if you go beyond int.

http://www.php.net/manual/en/language.types.integer.php

var_dump(PHP_INT_MAX);
$int = PHP_INT_MAX;
var_dump($int + $int);
0
source

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


All Articles