Reputation: 10390
The php documentation states:
If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead.
So I determined the integer max size
echo PHP_INT_MAX;
and got 2147483647.
I tested this statement out with
echo PHP_INT_MAX + PHP_INT_MAX;
and got 4294967294.
Shouldn't this be a float since I went beyond the max in integers?
Upvotes: 0
Views: 121
Reputation: 6265
It is actually a double, which is more precise than a single precision number (a float). This can be verified:
echo gettype(PHP_INT_MAX + PHP_INT_MAX);
Echoes: double
Upvotes: 0
Reputation: 1164
You're echo'ing the result so, it's already cast to a string.
This might help:
$result = PHP_INT_MAX;
echo gettype($result); // prints "integer"
$result2 = $result + $result;
echo gettype($result2); // prints "double"
Upvotes: 2