illzz wrote:But i'm still kind of confused on why we got the results we did (-285168042)....
PHP uses the IEEE-754 format to represent floating-point numbers. In 64 bits, to be precise. So it can represent numbers of the form $s$m(1<<$e) - where $s = +/-1 (the sign bit), 0 < $m < (1<<53) (the mantissa) and -1075 <= $e <= 970 (the exponent).
For 115678948950 those values are
$s = 1
$e = 0
$m = 115678948950
Written out in 64 bits that's
00000000000000000000000000011010 11101111000000001010111001010110
seeeeeeeeeeemmmmmmmmmmmmmmmmmmmm mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
(The sign bit is 0 for positive numbers, 1 for negative).
A PHP integer is only 32 bits of that: the rightmost 32 bits. So when you force that into an integer you're left with
11101111000000001010111001010110
The leftmost bit of that is a 1 so this represents a negative integer (two's complement notation is used). So to make it a positive integer you flip all the bits and add 1.
00010000111111110101000110101010
That's the binary representation of 285168042. So the negative integer was -285168042.
My confusion is where the 2147483647 came from. What version of PHP / what platform was this running on?