I have tried to cast signed int to unsigned int for 32-bit in php. but i could not able to get the absolute value for the unsigned int.
example:
$value = 65547;
if (PHP_INT_SIZE == 8)
{
if ($value>0x7FFFFFFF)
{
$value-=0x100000000;
}
}
Is any other possibilities to cast signed integer value to unsigned integer value?
http://php.net/manual/en/function.gmp-abs.php
For php7 you will need the php7.0-gmp package
For php5 you will need the php5-gmp package
var_dump((int) gmp_abs("0x7FFFFFFF"));
... returns
int(2147483647)
User contributions licensed under CC BY-SA 3.0