Microchip Technology SW006022-2N Data Sheet

Page of 338
Supported Data Types and Variables
 2012 Microchip Technology Inc.
DS52071B-page 101
6.8
LITERAL CONSTANT TYPES AND FORMATS
A literal constant is used to represent a numerical value in the source code; for exam-
ple, 123 is a constant. Like any value, a literal constant must have a C type. In addition 
to a literal constant’s type, the actual value can be specified in one of several formats. 
The format of integral literal constants specifies their radix. MPLAB XC16 supports the 
ANSI standard radix specifiers as well as ones which enables binary constants to be 
specified in C code.
The formats used to specify the radices are given in Table 6-3. The letters used to spec-
ify binary or hexadecimal radices are case insensitive, as are the letters used to specify 
the hexadecimal digits.
Any integral literal constant will have a type of int, long int or long long int, 
so that the type can hold the value without overflow. Literal constants specified in octal 
or hexadecimal may also be assigned a type of unsigned int, unsigned long 
int
 or unsigned long long int if the signed counterparts are too small to hold 
the value.
The default types of literal constants may be changed by the addition of a suffix after 
the digits, e.g. 23U, where U is the suffix. Table 6-4 shows the possible combination of 
suffixes and the types that are considered when assigning a type. So, for example, if 
the suffix l is specified and the value is a decimal literal constant, the compiler will 
assign the type long int, if that type will hold the lineal constant; otherwise, it will 
assigned long long int. If the literal constant was specified as an octal or 
hexadecimal constant, then unsigned types are also considered.
TABLE 6-3:
RADIX FORMATS
Radix
 Format
 Example
binary
 0b number or 0B number
 0b10011010
octal
 0 number
 0763
decimal
 number
 129
hexadecimal
 0x number or 0X number
 0x2F
TABLE 6-4:
SUFFIXES AND ASSIGNED TYPES
Suffix
Decimal
Octal or Hexadecimal
u
 or U
unsigned int
unsigned long int
unsigned long long int
unsigned int
unsigned long int
unsigned long long int
l
 or L
long int
long long int
long int
unsigned long int
long long int
unsigned long long int
u
 or U, and l or L
unsigned long int
unsigned long long int
unsigned long int
unsigned long long int
ll
 or LL
long long int
long long int
unsigned long long int
u
 or U, and ll or LL
unsigned long long int
unsigned long long int