Operators
An operator in computer science is usually a symbol or a set of symbols that represent an action. It tells the programme to perform a specific set of instructions or calculations.
Arithmetic Operators
Arithmetic operators are used to perform maths operations:
| Operator | Definition |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| %% | Modulus: returns the remainder of the division of the number to the left by the number on its right |
| %/% | Quotient: returns the quotient by integral division |
| ^ | Exponential |
Relational Operators
Relational operators are used to compare two values:
| Operator | Description |
|---|---|
> | TRUE when first value is greater than second value |
< | TRUE when first value is smaller than second value |
<= | TRUE when first value is less than or equal to second value |
>= | TRUE when first value is greater than or equal to second value |
== | TRUE when first value is equal to second value |
!= | TRUE when first value is not equal to second value |
Logical Operators
| Operator | Definition |
|---|---|
| & | AND operator (element-wise) |
| && | AND operator (vector-wise) |
| ! | Logical NOT (will return a statement as FALSE, if it is TRUE) |
| I | OR Operator (element-wise) |
| II | OR operator (vector wise) |