mikroC
making it simple...
Binary Arithmetic Operators
Division of two integers returns an integer, while remainder is simply truncated:
/* for example: */
7 / 4;
7 * 3 / 4;
/* but: */
7. * 3./ 4.;
Remainder operand % works only with integers; sign of result is equal to the sign
of first operand:
/* for example: */
9 % 3;
7 % 3;
-7 % 3;
We can use arithmetic operators for manipulating characters:
'A' + 32;
'G' - 'A' + 'a';
Unary Arithmetic Operators
Unary operators
(e.g.
When used as prefix, operators
subtract one from the value of operand before the evaluation. When used as suffix,
operators
ation.
For example:
int j = 5; j = ++k;
/* k = k + 1, j = k, which gives us j = 6, k = 6 */
int j = 5; j = k++;
/* j = k, k = k + 1, which gives us j = 5, k = 6 */
MikroElektronika: Development tools - Books - Compilers
// equals 1
// equals 5
// equals 5.25 as we are working with floats
// equals 0
// equals 1
// equals -1
// equals 'a' (ASCII only)
// equals 'g' (both ASCII and EBCDIC)
and
are the only operators in C which can be either prefix
++
--
,
) or postfix (e.g.
++k
--k
and
add or subtract one from the value of operand after the evalu-
++
--
mikroC - C Compiler for Microchip PIC microcontrollers
,
).
k++
k--
and
(preincrement and predecrement) add or
++
--
page
103
Need help?
Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?