Writing Expressions
In a language like IC, all expressions are simplified down to either true or false. A false expression is one that equals 0. A true expression is one that equals any non-zero number.
Expression Conditionals
The following items can be used to form conditional expressions.
| Syntax | Description | True Example | False Example |
|---|---|---|---|
| == | Equal To | 3==3 | 3==2 |
| != | Not Equal To | 3!=2 | 3!=3 |
| > | Greater Than | 3>2 | 3>3 |
| < | Less Than | 2<3 | 3<2 |
| >= | Greater Than Or Equal To | 3>=3 | 2>=3 |
| <= | Less Than Or Equal To | 2<=3 | 3<=2 |
| Not | Inverts The Expression | !0 | !1 |
| && | True If Both Expressions Are True | (3 > 2) && (!0) | (3 == 3) && (4 <= 2) |
| || | True If Either Expression is True | (3 == 3) || (4 <= 2) | (!1) || (2 > 3) |
Note, expressions are not limited to just numbers. They can contain variables or functions (ex. sonar() ).