Integers
An integer is a number of the set Z = {..., -2, -1, 0, 1,
2, ...}.
See also: Arbitrary length integer / GMP, Floating point
numbers, and Arbitrary precision / BCMath
Syntax
Integers can be specified in decimal (10-based), hexadecimal
(16-based) or octal (8-based) notation, optionally preceded
by a sign (- or +).
If you use the octal notation, you must precede the number
with a 0 (zero), to use hexadecimal notation precede the
number with 0x. Example 6-1. Integer literals
<?php
$a = 1234; # decimal number
$a = -123; # a negative number
$a = 0123; # octal number (equivalent to 83 decimal)
$a = 0x1A; # hexadecimal number (equivalent to 26 decimal)
?>
Formally the possible structure for integer literals is:
decimal : [1-9][0-9]*
| 0
hexadecimal : 0[xX][0-9a-fA-F]+
octal : 0[0-7]+
integer : [+-]?decimal
| [+-]?hexadecimal
| [+-]?octal
The size of an integer is platform-dependent, although a
maximum value of about two billion is the usual value (that's
32 bits signed). PHP does not support unsigned integers.
|