Section 2: Compiler
55
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
An integer constant can be represented in three different bases: octal, decimal,
and hexadecimal. A constant’s base is determined by its leading character(s).
Octal constants begin with a zero, and hexadecimal constants begin with the
character pair 0x or 0X. Decimal constants begin with any nonzero digit.
Examples of integer constants include:
15092
0xf9a
0XF9al
03510
275uL
319LU
The type of an integer constant is determined by its value, base, and suffix (if
any) according to the following rules:
1. The type of a decimal constant with no suffix is the first type in the following
list in which its value can be represented: int, long int, unsigned long int.
2. The type of an octal or hexadecimal constant with no suffix is the first type in
the following list in which its value can be represented: int, unsigned int,
long int, unsigned long int.
3. The type of a constant with only the
u
(or
U
) suffix is the first type in the
following list in which its value can be represented: unsigned int, unsigned
long int.
4. The type of a constant with only the
l
(or
L
) suffix is the first type in the
following list in which its value can be represented: long int, unsigned long
int.
5. The type of a constant with both the
u
(or
U
) suffix and the
l
(or
L
) suffix is
unsigned long int.
For example, the constant 0x81234567 is recognized as an unsigned long int,
because it cannot be represented as a 32-bit signed long int.
2.7.3. Enumeration
Constants
An identifier declared as an enumeration constant has type int. An enumeration
constant can be used anywhere an integer constant is allowed; however, there
are some restrictions when an enumeration constant is assigned to an
enumeration variable. See section 2.9.5 Enumeration Types, for additional
information.