p(PHP_INT_MAX, 'PHP_INT_MAX');p(~PHP_INT_MAX, 'interpreted to be one more than PHP_INT_MAX');

if (PHP_INT_SIZE == 4) {$note = 'interpreted to be the largest unsigned integer';} else {$note = 'interpreted to be the largest unsigned integer (18446744073709551615) but skewed by float precision';}p(-1, $note);

The "smartbindec" function I wrote below will convert any binary string (of a reasonable size) to decimal. It will use two's complement if the leftmost bit is 1, regardless of bit length. If you are getting unexpected negative answers, try zero-padding your strings with sprintf("%032s", $yourBitString).