User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
179
Constants
Constants or literals are tokens representing xed numeric or character values.
The mikroC PRO for PIC32 supports:
- integer constants
- oating point constants
- character constants
- string constants (strings literals)
- enumeration constants
The data type of a constant is deduced by the compiler using such clues as a numeric value and format used in the
source code.
Integer Constants
Integer constants can be decimal (base 10), hexadecimal (base 16), binary (base 2), or octal (base 8). In the absence
of any overriding sufxes, the data type of an integer constant is derived from its value.
Long and Unsigned Sufxes
The sufx L (or l) attached to any constant forces that constant to be represented as a long. Similarly, the sufx U (or
u) forces a constant to be unsigned. Both L and U sufxes can be used with the same constant in any order or case:
ul, Lu, UL, etc.
In the absence of any sufx (U, u, L, or l), a constant is assigned the “smallest” of the following types that can
accommodate its value: short, unsigned short, int, unsigned int, long int, unsigned long int.
Otherwise:
- If a constant has the U sufx, its data type will be the rst of the following that can accommodate its value:
unsigned short, unsigned int, unsigned long int.
- If a constant has the L sufx, its data type will be the rst of the following that can accommodate its value:
long int, unsigned long int.
- If a constant has both L and U sufxes, (LU or UL), its data type will be unsigned long int.
Decimal
Decimal constants from -2147483648 to 4294967295 are allowed. Constants exceeding these bounds will produce
an “Out of range” error. Decimal constants must not use an initial zero. An integer constant that has an initial zero is
interpreted as an octal constant. Thus,
int i = 10; /* decimal 10 */
int i = 010; /* decimal 8 */
int i = 0; /* decimal 0 = octal 0 */