Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 124 2012-2013 Microchip Technology Inc.
8.9 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 constants 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 8-4. 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 8-5 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 8-4: 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 8-5: 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

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh