36
5.6 Operators
The following are the operators used for calculations, which involves variables.
Arithmetic operators Signs
Addition
Subtraction
Multiplication
Division
Power
Integer division
Integer remainder of integer division
+,-
+
-
*
/
^
¥
MOD
Relational operators Equal to
Does not equal
Less than
Grater than
Less than or equal to
Grater than or equal to
=
<>, ><
<
>
=>, <=
=>, >=
Logical operators
Negation
Logical product
Logical sum
Exclusive OR
NOT
AND
OR
XOR
Operators
String operator
Concatenation
+
Relational operators
Relational operations can be performed only when the operators are both strings or
both numeric values.
With strings, character codes are compared one-by-one from the beginning of the
strings. This is to say that the first position of string A is compared to the first position
of string B, the second position of string A with the second position of string B, etc.
The result of the comparison is based upon the character codes of the first difference
between the strings detected, regardless of the length of the strings being compared.
EXAMPLES
:
STRING A
STRING B RESULT
ABC
ABC
A=B
ABC
ABCDE
A<B
ABC
XYZ
A<B (character code for A less than that for X)
XYZ
ABCDE
A>B (character code for X greater than that for A)
A result of -1 is returned when the result of a relational operation is true (condition
met), while 0 is returned when the return is false (conditions not met)
EXAMPLE
:
10 PRINT 10>3
-1 returned because 10>3 is true
20 PRINT 7>1
0 returned because 7<1 is false
30 PRINT “ABC”=3XYZ”
0 returned because ABC=XYZ is false
40 END