
78
6.2 Operator Precedence
When an expression contains more than one operator, BHT-BASIC performs the operations
in the standard precedence as shown below.
Precedence
1.
1.1.
1.
Parentheses ( )
Parentheses ( ) Parentheses ( )
Parentheses ( )
The parentheses allow you to override operator precedence; that is, operations
enclosed with parentheses are first carried out.
For improving the readability of an expression, you can use parentheses to separate
two operators placed in succession.
2.
2. 2.
2.
Function operations
Function operationsFunction operations
Function operations
3.
3.3.
3.
Arithmetic operations
Arithmetic operations Arithmetic operations
Arithmetic operations
Operations Arithmetic Operators Precedence
Negation
Multiplication and division
Modulo arithmetic
Addition and subtraction
-
* and /
MOD
+ and -
1
2
3
4
4.
4. 4.
4.
Relational operations
Relational operationsRelational operations
Relational operations
=,<>,><,<,>,<=,>=,=<,=>
5.
5. 5.
5.
Logical operations
Logical operationsLogical operations
Logical operations
Operations Logical Operators Precedence
Logical negation
Logical multiplication
Logical addition
Exclusive logical addition
NOT
AND
OR
XOR
1
2
3
4
6.
6.6.
6.
String operations
String operations String operations
String operations
When more than one operator occurs at the same level of precedence, the BHT-BASIC
resolves the expression by proceeding from left to right.
a=4+5.0/20*2-1
In the above example, the operation order is as follows;
5.0/20 (=0.25)
0.25*2 (=0.5)
4+0.5 (=4.5)
4.5-1 (=3.5)
Kommentare zu diesen Handbüchern