Comparisons

A comparison is a special type of expression that delivers either true (nonzero) or false (zero) as a result. There are special comparison operators for comparing variables or expressions:

== True if the expressions left and right of the operator are equal.
!= True if the expressions left and right of the operator are not equal.
> True if the expression left of the operator is greater than the expression right of the operator.
>= True if the expression left of the operator is greater than or equal to the expression right of the operator.
< True if the expression right of the operator is greater than the expression left of the operator.
<= True if the expression right of the operator is greater than or equal to the expression left of the operator.
and, && True if the expressions left and right of the operator are both true.
or, || True if any one of the expressions left and right of the operator is true.
not, ! True if the expression right of the operator is not true.
() Brackets, for defining the priority of comparisions. Always use brackets when priority matters!

Remarks:

Examples:

10 < x // true if x is greater than 10
(10 <= x) and (15 => x) // true if x is between 10 and 15
!((10 <= x) and (15 => x)) // true if x is less than 10 or greater than 15 (lite-C only)

See also:

Functions, Variables, Pointers, Expressions

 

► latest version online