Relational operations, Logical operators – MITSUBISHI ELECTRIC T-60 User Manual

Page 47

Advertising
background image

Relational Operations

Relational operators let you compare two values. The result of the
comparison is either true (-1) or false (0). This result can then be used to

make a decision regarding program flow.

=

Equality

X = Y

<>

Inequality

X <> Y

<

Less than

X < Y

>

Greater than

X > Y

<=

Less than or equal to

X <= Y

>=

Greater than or equal to

X >= Y

The equal sign is also used to assign a value to a variable.

When arithmetic and relational operators are combined in one expression,
the arithmetic is always performed first:

X+Y < (T-1)/Z

This expression is true if the value of X plus Y is less than the value of T-1
divided by Z.

Logical Operators

Logical operators perform tests on multiple relations, bit manipulation, or

boolean operations. The logical operator returns a bit-wise result which is
either true (not zero) or false (zero). In an expression, logical operations are
performed after arithmetic and relational operations. The following table

lists the availabe logical operators.

Operator:

Operation:

NOT

Logical negation

AND

Logical AND

OR

Logical OR

XOR

Logical exclusive OR

Just as the relational operators can be used to make decisions regarding

program flow, logical operators can connect two or more relations and return
a true or false value to be used in a decision. For example:

IF D<200 AND F<4 THEN 80

IF I>10 OR K<0 THEN 50

IF NOT P THEN 100

T-60 Basic Programming Language

Logical Operators

39

Advertising