mikroC
mikroC - C Compiler for Microchip PIC microcontrollers
making it simple...
Use relational operators to test equality or inequality of expressions. If the expression evaluates to true, it returns 1; otherwise it returns 0.
All relational operators associate from left to right.
Relational Operators Overview
Operator | Operation | Precedence |
|
|
|
== | equal | 9 |
|
|
|
!= | not equal | 9 |
|
|
|
> | greater than | 10 |
|
|
|
< | less than | 10 |
|
|
|
>= | greater than or equal | 10 |
|
|
|
<= | less than or equal | 10 |
|
|
|
Relational Operators in Expressions
Precedence of arithmetic and relational operators was designated in such a way to allow complex expressions without parentheses to have expected meaning:
page
104
a + 5 >= c - 1.0 / e // i.e. (a + 5) >= (c - (1.0 / e))
Always bear in mind that relational operators return either 0 or 1. Consider the following examples:
8 == 13 > 5 // returns 0: 8==(13>5), 8==1, 0
14 > 5 < 3 // returns 1: (14>5)<3, 1<3, 1
a < b < 5// returns 1: (a<b)<5, (0 or 1)<5, 1
MikroElektronika: Development tools - Books - Compilers