|
B.2 Mathematical and Logical Operators
|
Sheerpower supports the following mathematical operators:
+ addition
- subtraction
* multiplication
/ division
^ exponentiation
++ increment a variable's value.. For example: counter++
Sheerpower supports the following logical operators:
< less than X is less than Y
<= less than or equal to X is less than or equal to Y
= equals X is equal to Y
> greater than X is greater than Y
>= greater than or equal to X is greater than or equal to Y
<> not equal to X is not equal to Y
!= not equal to X is not equal to Y
NOT NOT X TRUE if X is false
AND X AND Y TRUE if X and Y are both true
OR X OR Y TRUE if either X or Y are true
XOR X XOR Y TRUE if X is true, or if Y is true, FALSE if X and Y are both true or both false
IMP X IMP Y TRUE if X is true and Y is false
EQV X EQV Y TRUE if X and Y are true, or
TRUE if X and Y are false, FALSE otherwise
In addition there are a lot of built-in mathematical functions.
See
common math functions
and
transcendental functions for details.
Order of Evaluation
Sheerpower always evaluates expressions in parentheses first. Parentheses,
( ), can be used to
change the order of any of the following operations. If parentheses are nested,
Sheerpower evaluates them from the inside out. For example:
Z - (X / (Y+AMOUNT))
Sheerpower evaluates the expression
Y + AMOUNT first. Next, it
divides the X by that result.
Finally, it
subtracts the entire expression from Z.
- Sheerpower performs functions second.
- Sheerpower performs exponentiation.
- Sheerpower performs multiplication and division.
- Sheerpower performs addition and subtraction.
- Sheerpower performs relational operations from left to right.
(The relational operators are: =, <, >, <=, >= and <>.) The only exception is the assignment of the
result. The result is always assigned last.
Sheerpower performs logical operations in the following order:
NOT
AND
OR
XOR
IMP
EQV
For clarity,
Parentheses can be used around every set of operations. This makes it easy to
pick out the beginning and end of an operation, and will make absolutely
clear what is intended without depending on the order of precedence of
operators.