HP C/iX Reference Manual (31506-90011)
Chapter 2 21
Lexical Elements
Integer Constants
Description
An integer constant begins with a digit, but has no period or exponent part. It may have a
prefix that specifies its base (decimal, octal, or hexadecimal) and suffix that specifies its
type.
The size and type of integer constantsare described in Chapter 9, HP C/iX Implementation
Topics.
Octal constants begin with a zero and can contain only octal digits. Several examples of
octal constants are:
077 01L 01234567 0222l
Hexadecimal constants begin with either 0x or 0X. The case of the x character makes no
difference to the constant's value. The following are examples of hexadecimal constants:
0xACE 0XbAf 0x12L
The suffix L or l stands for long. The suffix U or u stands for unsigned. Both can be used on
all three types of integer constants (decimal, octal, and hexadecimal).
The type of an integer constant is the first of the corresponding list in which its value can
be represented, as described below.
• Unsuffixed decimal: int, unsigned long int.
• Unsuffixed octal or hexadecimal: int, unsigned int.
• Suffixed by the letter u or U: unsigned int.
• Suffixed by the letter l or L: long int,
unsigned long int.
• Suffixed by both the letters u or U and l or L: unsigned long int.
Examples
0xFFFFu
unsigned int, hexadecimal
4196L
signed long int, decimal
0X89ab
signed int, hexadecimal
047L
signed long int, octal
64U
unsigned int, decimal
15
signed int, decimal
15L
signed long int, decimal
15U
unsigned int, decimal
15UL
unsigned long int, decimal
15LU
unsigned long int, decimal
0125
signed int, octal