mikroC
making it simple...
mikroC - C Compiler for Microchip PIC microcontrollers
Binary Arithmetic Operators
Division of two integers returns an integer, while remainder is simply truncated:
/* for example: */
7 | / | 4; | // equals 1 |
7 | * | 3 / 4; | // equals 5 |
/* but: */
7.* 3./ 4.; // equals 5.25 as we are working with floats
Remainder operand % works only with integers; sign of result is equal to the sign of first operand:
/* for example: */ |
| ||||
9 | % | 3; | // | equals | 0 |
7 | % | 3; | // | equals | 1 |
% | 3; | // | equals |
We can use arithmetic operators for manipulating characters:
'A' + 32;// equals 'a' (ASCII only)
'G' - 'A' + 'a'; // equals 'g' (both ASCII and EBCDIC)
Unary Arithmetic Operators
Unary operators ++ and
When used as prefix, operators ++ and
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 */
|
| page |
|
MikroElektronika: Development tools - Books - Compilers | 103 | ||
|
|