Numeric literals
There are four types of numeric literals: plain integers, long integers, floating point numbers, and imaginary numbers.
There are no complex literals; complex numbers can be formed by adding a real number and an imaginary number.
Note that numeric literals do not include a sign; a phrase like -1
is actually an expression composed of the unary operator - and the
literal 1.
Integer literals #
Integer and long integer literals are described by the following lexical definitions:
longinteger ::= [ integer][1] ("l" | "L")
integer ::= [decimalinteger][2] | [ octinteger][3] | [hexinteger][4]
decimalinteger ::= [ nonzerodigit][5] [digit][6]\* | "0"
octinteger ::= "0" [ octdigit][7]+
hexinteger ::= "0" ("x" | "X") [hexdigit][8]+
nonzerodigit ::= "1"..."9"
octdigit ::= "0"..."7"
hexdigit ::= [ digit][6] | "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”