|
Logical operators
Operator |
Description |
AND |
Logical "AND", conjunction. TRUE if both arguments are TRUE, otherwise FALSE. If the arguments are numbers, performs bitwise comparison.
Example:
2>3 AND 2<5 returns TRUE
2 AND 3 returns 2 (bitwise comparison) |
EQV |
Used to perform a logical equivalence on two expressions. For logical expressions returns TRUE only if both expressions evaluate to TRUE, or if both expressions evaluate to FALSE. The same (only bitwise) applies to numeric expressions.
The following table illustrates how result is determined:
For logical expressions.
A |
B |
A EQV B |
True |
True |
True |
True |
False |
False |
False |
True |
False |
False |
False |
True |
For numeric expressions.
a |
b |
a EQV b |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
|
IMP |
Used to perform a logical implication on two expressions. For numeric expressions works bitwise.
The following table illustrates how result is determined:
For logical expressions.
A |
B |
A IMP B |
True |
True |
True |
True |
False |
False |
False |
True |
True |
False |
False |
True |
For numeric expressions.
a |
b |
a IMP b |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
|
NOT or ! |
Used to perform logical negation on an expression. For numeric expressions works bitwise.
The NOT A and !A forms are fully equivalent.
The following table illustrates how result is determined:
For logical expressions.
A |
NOT A |
True |
False |
False |
True |
For numeric expressions.
|
OR |
Used to perform a logical disjunction on two expressions. Returns TRUE if at least one of the expressions is TRUE, otherwise returns FALSE. For numeric expressions works bitwise.
The following table illustrates how result is determined:
For logical expressions.
A |
B |
A OR B |
True |
True |
True |
True |
False |
True |
False |
True |
True |
False |
False |
False |
For numeric expressions.
a |
b |
a OR b |
1 |
1 |
1 |
1 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
0 |
|
XOR |
Used to perform a logical exclusion on two expressions. Returns TRUE only if one of the two expressions is TRUE, and the other is FALSE.
The following table illustrates how result is determined:
For logical expressions.
A |
B |
A XOR B |
True |
True |
False |
True |
False |
True |
False |
True |
True |
False |
False |
False |
For numeric expressions.
a |
b |
a XOR b |
1 |
1 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
0 |
|
Comparison Operators
The operators <, >, <=, >=, =, <> are used to compare two expressions.
Syntax:
<result>=<expression1> <comparison_operator> <expression2>.
Arithmetic Operators
Arithmetic operators are: Exponentiation ^ or **; negation/subtraction-; adding+; multiplication and division *, /; integer division \; modulo arithmetic MOD; string concatenation &.
Operator |
Description |
^ or ** |
Used to raise a number to the power of an exponent.
Example:
2**10 results in 1024. |
- |
Used to find the difference between two numbers or to indicate the negative value of a numeric expression.
Example:
-5
-(-3) equals 3. |
+ |
Used to sum two expressions. Returns a Boolean value if both expressions are Boolean, or a numeric value if both expressions are numeric. For string expressions, concatenates the strings. If one of the expressions is a string, and the other is not a string - the non-string is converted to a string and both strings are concatenated.
Example:
1+1 results in 2,
2+"some string" results in "2some string",
"some string"+234 results in "some string234". |
- |
Subtracts one expression from the other.
Example:
1-3 equals -2,
7-4 equals 3.
|
* |
Used to multiply two expressions. |
/ |
Used to divide two expressions and return a floating-point result. Division by zero returns the first expression and no error occurs. |
\ |
Used to divide two numbers and return an integer result.
Example:
11 \ 4 equals 2
9 \ 2 equals 4 |
MOD |
Used to divide two numbers and return only the remainder.
Example:
10 MOD 3 returns 1
8 MOD 5 returns 3
8 MOD 3 returns 2 |
& |
Used to force string concatenation of two expressions. Returns a String value. If an expression is not a string, it is converted to a string prior to the operation.
Example:
"some "&"string" returns "some string",
34&"string" returns "34string",
45&56 returns the string "4556".
Note: In fact, this operator is not arithmetic, but belongs to this group because it has the same precedence as other arithmetic operators. |
Note: Negation and Subtraction are different operators with different precedence, though they are denoted with the same sign "-".
Operator Precedence
When several operations occur in an expression, each part is evaluated and resolved in a predetermined order. That order is known as operator precedence. Parentheses can be used to override the order of precedence and force some parts of an expression to be evaluated before others. Operations within parentheses are always performed before those outside. Within parentheses, however, normal operator precedence is maintained.
The operators, supported in ConceptDraw, can be divided into 3 groups: arithmetic, comparison, logical. When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last.
Within individual categories, operators are evaluated in the order of precedence shown below:
Arithmetic Operators |
Comparison Operators |
Logical Operators |
^ or ** |
= |
NOT |
negation"-" |
<> |
AND |
*, / |
< |
OR |
\ |
> |
XOR |
MOD |
<= |
EQV |
+, - |
>= |
IMP |
& |
|
|
«
|