Integers can be specified using any of the following syntaxes:
$a = 1234; # decimal number $a = -123; # a negative number $a = 0123; # octal number (equivalent to 83 decimal) $a = 0x12; # hexadecimal number (equivalent to 18 decimal) |
Because of the flexible type-juggling, a number is autmatically converted to float when it is about to overflow.
See type-juggling for general information about converting.
When converting from float to integer, the number will be rounded towards zero.
If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31), the result is undefined, since the float hasn't got enough precision to give an exact integer result.
Warning |
No warning, not even a notice will be issued in this case! |
Warning |
Never cast an unknown fraction to integer, as this can sometimes lead to unexpected results. See for more information the warning about float-precision. |
See also: Arbitrary precision integeres and Floating point numbers