User manual
182
mikoC PRO for dsPIC
MikroElektronika
Constants
Constants or literals are tokens representing xed numeric or character values.
The mikroC PRO for dsPIC30/33 and PIC24 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 sufxes, the data type of an integer constant is derived from its value.
Long and Unsigned Sufxes
The sufx L (or l) attached to any constant forces that constant to be represented as a long. Similarly, the sufx U (or
u) forces a constant to be unsigned. Both L and U sufxes can be used with the same constant in any order or case:
ul, Lu, UL, etc.
In the absence of any sufx (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 sufx, 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 sufx, 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 sufxes, (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 */