Remote Processing CAMBASIC User Manual
Page 16

Concepts - 10
>
greater than
X> Y
<
less than
X< Y
> =
greater than
X> = Y
or equa l to
< =
less than
X< = Y
or equa l to
Relational operations return a value of “0” if false, – “1” if true.
Logical Operators
Logical operators perform logical, or Boolean operations on numeric values. Just as relational operators usually make
decisions regarding program flow, logical operators usually connect two or mor e relations and return a true or false value
to be used in a decision (see “IF statement” in CA MBASIC COM MAN DS).
A logical operator takes a combination of true– false values and returns a true or false result. An operand of a logical
operato r is conside red “ true” if it is not equal to zer o (like the – 1 retur ned by a r elational oper ator), or “ false” if it is
equal to zer o. T he result of the logical oper ation is a num ber w hich is, again, “tr ue” if it is not equal to zer o, o r “ false” if
it is equal to zer o. T he numb er is calcu lated by per form ing the oper ation, bit by bit.
The logical operators are NOT, AN D, X OR and OR. In the following table. (“ T” indicates a true, or nonzero value.
“F ” indicates a false, or zero value. ). The operators are listed in order of precedence.
A
NOT A
A
B
A A N D B
T
F
T
T
T
F
T
T
F
F
F
T
F
T
F
F
F
F
F
F
A
B
A OR B
A
B
A XOR B
T
T
T
T
T
F
T
F
T
T
F
T
F
T
T
F
T
T
F
F
F
F
F
F
Logical operations are carried out on 16– bit operands with 16– bit results. The examples use 8– bit operands for
simplicity.
The OR oper ator essentially detects the presence of a binary “ 1” in either operand. For example:
Operand 1
0001 0111
=
23
Operand 2
0100 1010
=
74
Operand 1
0101 1111
=
95
OR Oper and 2
The AND operator detects the coincidence of two binary “ 1”s.
Operand 1
0001 0111
=
23
Operand 2
0100 1010
=
74
Operand 1
0000 0010
=
2