Integer literals have two possible forms: decimal and hexadecimal.
The type of an integer literal is determined as follows:
int
, uint
, long
, ulong
.U
or u
, it has the first of these types in which its value can be represented: uint
, ulong
.L
or l
, it has the first of these types in which its value can be represented: long
, ulong
.UL
, Ul
, uL
, ul
, LU
, Lu
, lU
, or lu
, it is of type ulong
.If the value represented by an integer literal is outside the range of the ulong
type, an error occurs.
To permit the smallest possible int
and long
values to be written as decimal integer literals, the following two rules exist:
-
operator (§7.6.2), the result is a constant of type int
with the value -2147483648 (-231). In all other situations, such a decimal-integer-literal is of type uint
.L
or l
appears as the operand of the unary -
operator (§7.6.2), the result is a constant of type long
with the value -9223372036854775808 (-263). In all other situations, such a decimal-integer-literal is of type ulong
.