Specifications

Concepts - 10
> greater than X>Y
< less than X<Y
>= greater than X>=Y
or equal to
<= less than X<=Y
or equal 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 more relations and return a true or false value to
be used in a decision (see “IF statement” in CAMBASIC COMMANDS).
A logical operator takes a combination of true–false values and returns a true or false result. An operand of a logical
operator is considered “true” if it is not equal to zero (like the –1 returned by a relational operator), or “false” if it is equal
to zero. The result of the logical operation is a number which is, again, “true” if it is not equal to zero, or “false” if it is
equal to zero. The number is calculated by performing the operation, bit by bit.
The logical operators are NOT, AND, XOR 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 AND 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 operator 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 Operand 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
AND Operand 2