|
| mikroC | |
mikroC - C Compiler for Microchip PIC microcontrollers | making it simple... | ||
|
|
|
|
Logical Expressions and Side Effects
General rule with complex logical expressions is that the evaluation of consecutive logical operands stops the very moment the final result is known. For example, if we have an expression:
a && b && c
where a is false (0), then operands b and c will not be evaluated. This is very important if b and c are expressions, as their possible side effects will not take place!
Logical vs. Bitwise
Be aware of the principle difference between how bitwise and logical operators work. For example:
0222222 | & | 0555555 | /* equals 000000 */ | ||||
0222222 | && | 0555555 | /* | equals | 1 | */ | |
~ | 0x1234 |
|
| /* equals 0xEDCB */ | |||
! | 0x1234 |
|
| /* | equals | 0 | */ |
page |
|
108 | MikroElektronika: Development tools - Books - Compilers |
|