note 96262 modified in function.crc32 by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Feb 2010 18:27:31 +0000 |
| Subject: | note 96262 modified in function.crc32 by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166088@lists.php.net to get a copy of this message | ||
This function returns an unsigned integer from a 64-bit Linux platform. It does return the signed
integer from other 32-bit platforms even a 64-bit Windows one.
The reason is because the two constants PHP_INT_SIZE and PHP_INT_MAX have different values on the
64-bit Linux platform.
I've created a work-around function to handle this situation.
<?php
function get_signed_int($in) {
$int_max = pow(2, 31)-1;
if ($in > $int_max){
$out = $in - $int_max * 2 - 2;
}
else {
$out = $in;
}
return $out;
}
?>
Hope this helps.
--was--
This function returns an unsigned integer from a 64-bit Linux platform. It does return the signed
integer from other 32-bit platforms even a 64-bit Windows one.
The reason is because the two constants PHP_INT_SIZE and PHP_INT_MAX have different values on the
64-bit Linux platform.
I've created a work-around function to handle this situation.
function get_signed_int($in) {
$int_max = pow(2, 31)-1;
if ($in > $int_max){
$out = $in - $int_max * 2 - 2;
}
else {
$out = $in;
}
return $out;
}
Hope this helps.
http://php.net/manual/en/function.crc32.php