When I run this:
echo ((1 << 56) | (7 << 52) | 4437313);
32bit
PHP returns: 24360257
64bit
PHP returns: 103582791433958721
How would I go about returning the 64bit
answer on a 32bit
install of php?
I have the BC extension if that makes a difference?
You cannot shift more than 32 bits on a 32 bit processor.
The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5.
Don't know if it can be achieved with BC extension, but with GMP it is:
function gmp_shiftl($x,$n) {
return gmp_mul($x, gmp_pow(2, $n));
}
$res = gmp_or(gmp_or(gmp_shiftl('1','56'), gmp_shiftl('7','52')), '4437313');
echo gmp_strval($res);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.