Datasheet

/* for example: */
7 / 4; /* equals 1 */
7 * 3 / 4; /* equals 5 */
/* but: */
7. * 3. / 4.; /* equals 5.25 because we are working with floats */
Remainder operand % works only with integers; the sign of result is equal to the sign
of the first operand:
/* for example: */
9 % 3; /* equals 0 */
7 % 3; /* equals 1 */
-7 % 3; /* equals -1 */
Arithmetic operators can be used for manipulating characters:
'A' + 32; /* equals 'a' (ASCII only) */
'G' - 'A' + 'a'; /* equals 'g' (both ASCII and EBCDIC) */
Unary Arithmetic Operators
Unary operators ++ and -- are the only operators in C which can be either prefix
(e.g.
++k, --k) or postfix (e.g. k++, k--).
When used as prefix, operators
++ and -- (preincrement and predecrement) add or
subtract one from the value of the operand before the evaluation. When used as suf-
fix, operators
++ and -- (postincrement and postdecrement) add or subtract one
from the value of the operand after the evaluation.
For example:
int j = 5;
j = ++k; /* k = k + 1, j = k, which gives us j = 6, k = 6 */
but:
int j = 5;
j = k++; /* j = k, k = k + 1, which gives us j = 5, k = 6 */
196
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5