Datasheet
After this, any two values associated with an operator are either int (including the
long and unsigned modifiers) or float (equivalent with double and long double
in the mikroC PRO for AVR).
1. If either operand is float, the other operand is converted to float.
2. Otherwise, if either operand is
unsigned long, the other operand is con-
verted to unsigned long.
3. Otherwise, if either operand is
long, then the other operand is converted
to
long.
4. Otherwise, if either operand is unsigned, then the other operand is con-
verted to unsigned.
5. Otherwise, both operands are int.
The result of the expression is the same type as that of the two operands.
Here are several examples of implicit conversion:
2 + 3.1 /* ? 2. + 3.1 ? 5.1 */
5 / 4 * 3. /* ? (5/4)*3. ? 1*3. ? 1.*3. ? 3. */
3. * 5 / 4 /* ? (3.*5)/4 ? (3.*5.)/4 ? 15./4 ? 15./4. ? 3.75 */
Pointer Conversions
Pointer types can be converted to other pointer types using the typecasting mecha-
nism:
char *str;
int *ip;
str = (char *)ip;
More generally, the cast type* will convert a pointer to type “pointer to type”.
176
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5