PHP 8.5.0 Alpha 4 available for testing

Voting

: one plus three?
(Example: nine)

The Note You're Voting On

jian at theorchard dot com
15 years ago
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.

<< Back to user notes page

To Top