Elementary Operators
The CSL language supports a notation for elementary arithmetic, relational and logical operations similar to most other high-level programming languages.
Arithmetic Operators
Elementary arithmetic operators are represented by the +, -, *, /, ^ and ** tokens as follows:
+ Addition
- Subtraction
* Multiplication
/ Division
^ Power
** Power (alternative form)
Note that the subtraction operator may also be used as a unary negation: e.g., y = -x.
Relational Operators
Relational operators also follow the notation of languages like C/C++, Java and similar languages. Note that FORTRAN-style relational operators used in older CSL language versions are no longer supported. These operators include .EQ., .LT., .LE., etc. FORTRAN-style relational oerators must be replaced with their C- and Java-style equivalants.
== Equals
< Less than
<= Less than or equal
> Greater than
>= Greater than or equal
~= Not equal
Logical Operators
The logical "and" (conjunction) and "or" (disjunction) operators are also identical in use to the C/C++ and Java analogs. The unary "not" operator is denote by the "~" character, however, to avoid conflict with the CSL comment operator.
&& And
|| Or
~ Not
Order of Precedence
Order of precedence in the CSL language is similar to most modern programming languages. When it is desired to force a particular order of calculation, parentheses may be used. For arithmetic expressions, the following order of precedence is observed:
- Parenthesized expressions
- Exponentiation (right to left)
- Multiplication/division (right to left)
- Addition/subtraction (right to left)
For relational and logical expressions, the following order of precedence is observed:
- Relational operators (left to right)
- Unary negation (~)
- Conjunction (&&)
- Disjunction (||)