Datasheet
LOGICAL EXPRESSIONS AND SIDE EFFECTS
General rule regarding complex logical expressions is that the evaluation of consec-
utive logical operands stops at the very moment the final result is known. For exam-
ple, if we have an expression a&&b && cwhere 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 */
201
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5