Logical Operators - mikroElektronika PIC Microcontrollers PIC12 User Manual

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...

Logical Operators

Operands of logical operations are considered true or false, that is non-zero or
zero. Logical operators always return 1 or 0. Operands in a logical expression
must be of scalar type.
Logical operators
! associates from right to left.
Logical Operators Overview
Precedence of logical, relational, and arithmetic operators was chosen in such a
way to allow complex expressions without parentheses to have expected meaning:
c >= '0' && c <= '9'; // reads as: (c>='0') && (c<='9')
a + 1 == b || ! f(x;) // reads as: ((a+1)== b) || (!(f(x)))
Logical AND (
erwise returns 0. If the first expression evaluates to false, the second expression is
not evaluated. For example:
a > b && c < d;
// if (a>b) is false (0), (c<d) will not be evaluated
Logical OR (
erwise returns 0. If the first expression evaluates to true, the second expression is
not evaluated. For example:
a && b || c && d;
// if (a&&b) is true (1), (c&&d) will not be evaluated
MikroElektronika: Development tools - Books - Compilers
mikroC - C Compiler for Microchip PIC microcontrollers
and
associate from left to right. Logical negation operator
&&
||
Operator
&&
||
!
) returns 1 only if both expressions evaluate to be nonzero, oth-
&&
// reads as: (a>b) && (c<d)
) returns 1 if either of the expressions evaluate to be nonzero, oth-
||
// reads as: (a && b) || (c && d)
Operation
logical AND
logical OR
logical negation
Precedence
5
4
14
page
107

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents