Integer and long integer literals are described by the following lexical definitions:
longinteger |
::= | integer ("l" | "L") |
integer |
::= | decimalinteger | octinteger | hexinteger |
decimalinteger |
::= | nonzerodigit digit* | "0" |
octinteger |
::= | "0" octdigit+ |
hexinteger |
::= | "0" ("x" | "X") hexdigit+ |
nonzerodigit |
::= | "1"..."9" |
octdigit |
::= | "0"..."7" |
hexdigit |
::= | digit | "a"..."f" | "A"..."F" |
Although both lower case "l" and upper case "L" are allowed as suffix for long integers, it is strongly recommended to always use "L", since the letter "l" looks too much like the digit "1".
Plain integer decimal literals that are above the largest representable plain integer (e.g., 2147483647 when using 32-bit arithmetic) are accepted as if they were long integers instead. Octal and hexadecimal literals behave similarly, but when in the range just above the largest representable plain integer but below the largest unsigned 32-bit number (on a machine using 32-bit arithmetic), 4294967296, they are taken as the negative plain integer obtained by subtracting 4294967296 from their unsigned value. There is no limit for long integer literals apart from what can be stored in available memory. For example, 0xdeadbeef is taken, on a 32-bit machine, as the value -559038737, while 0xdeadbeeffeed is taken as the value 244837814107885L.
Some examples of plain integer literals (first row) and long integer literals (second and third rows):
7 2147483647 0177 0x80000000 3L 79228162514264337593543950336L 0377L 0x100000000L 79228162514264337593543950336 0xdeadbeeffeed
See About this document... for information on suggesting changes.