37
Logical Operators
The operands of logical operations are truncated to integers and the operation is
performed bit-by-bit to obtain the result.
X
Y
X AND Y
X OR Y
X XOR Y
NOT X
NOT Y
0
0
0
0
0
1
1
0
1
0
1
1
1
0
1
0
0
1
1
0
1
1
1
1
1
0
0
0
String Operators
Strings may be concatenated using a + sign. The result of the operation (including
intermediate results) may not exceed 255 characters.
EXAMPLE
:
A$=”AD”+”1990”
The above example results in the string “AD1990” being assigned to variable A$.
Order of Operations
Arithmetic, relational and logical operations are performed in the following order of
precedence:
1. ( , )
2. Scientific function
3. Power
4. Sign (+, -)
5. *, /, ¥, MOD
6. Addition and subtraction
7. Relational operators
8. NOT
9. AND
10. OR, XOR
Operations are performed from left to right when the order of precedence is identical.
5.7 Constants and Variables
5.7.1 Constants
The following shows the constants included in the sample program of page 33:
PROGRAM
20 R=15
30 INPUT “H=”;H
40 V=PI*R^2*H
50 PRINT “V=”;V
CONSTANTS
15
“H=”
2
“V=”
Of these, 15 and 2 are numeric constants, while “H=” and “V=” are string constants.