Here is the code:
echo sprintf('%u',-123);
And this is the output on 32 bit platform:
4294967173
but on 64 bit:
18446744073709551493
How to make it the same ?Say,the int(10) unsigned
Here is the code:
echo sprintf('%u',-123);
And this is the output on 32 bit platform:
4294967173
but on 64 bit:
18446744073709551493
How to make it the same ?Say,the int(10) unsigned
echo sprintf('-%u',abs(-123));
or
$n = -123;
echo sprintf("%s%u", $n < 0 ? "-":"", abs($n));
Though if you actually want to see the two's complement unsigned value of a negative number restricted to 32 bits just do:
echo sprintf("%u", $n & 0xffffffff);
And that will print 4294967173
on all systems.
Check out my answer to this question for some ideas - in a nutshell, you can check the value of the PHP_INT_SIZE constant to perform different processing on a 64bit platform.