2 - 20 2 - 20
MELSEC-Q
2 THE BASICS OF AD51H-BASIC
• Division when overflow occurs or when the divisor is 0.
If a divisor becomes 0 in a division while executing an expression, a “Division by
zero” error will occur. Also, if 0 is lifted to a negative power, a “Division by zero” error
will occur.
When an overflow occurs, an “Overflow” error will be generated.
• Mixing with other types of operators
An expression can contain logical operators, other than arithmetic operators. When
an expression contains a relational operator, the arithmetic operation is performed by
returning the value –1 if the result of the logical operation is True, and value 0 if the
result of the logical operation is False.
Example
(A=B)
(A>C)
(A AND MASK)/2
2.10.2 Relational operators
Relational operators are used to compare two values. The results of comparisons are
expressed as either “True” (-1) or “False” (0). Results such as these are used to
determine the program flow.
Operator
Meaning Example
= Equal to X=Y
<>, >< Not equal to X<>Y, X><Y
< Less than X<Y
> Greater than X>Y
<=, =< Less than or equal to X<=Y, X=<Y
>=, => Greater than or equal to X>=Y, X=>Y
The "equal to" symbol (=) is also used to assign a value
to a variable.
When a relational operator and an arithmetic operator both exist in the same equation,
the arithmetic operator will always take priority. The result is then used for the relational
operation.
Example
X+Y<(T-1)/Z • • • • •
The result is True if the value X + Y is less than
T-1
Z
SIN(X)<0 • • • • • The result is True if the value SIN(X) is less than 0.