2 - 19 2 - 19
MELSEC-Q
2 THE BASICS OF AD51H-BASIC
In order to change the order of operations, parentheses are used. When a portion of
an expression is surrounded by parentheses, the operation within the parentheses are
performed first. When an operator is followed by another operator, parentheses must
be used.
Operations on double-precision real numbers may be performed in arithmetic
operations, but numbers lifted to higher powers are all converted to single-precision.
Some algebraic numeric expressions and their corresponding BASIC expressions are
shown below.
Algebraic expression
BASIC expression
X+2Y
• • • • • • •
X+Y 2
X-
Y
Z
• • • • • • •
X-Y/Z
XY
Z
• • • • • • •
X Y/Z
X+Y
Z
• • • • • • •
(X+Y)/Z
(X
2
)
y
• • • • • • •
(X^2)^Y/
X
Y
Z
• • • • • • •
X^(Y^Z)
X(-Y)
• • • • • • •
X (-Y)
Note that the multiplication,
division, and power symbols
are different from their
mathematical symbols.
n
^ n
/
• Integer division and remainder operations
Integer division operations are expressed using ¥. Fractional portion of divisor,
dividend, and the quotient are dropped before the operation and rounded to integers.
Example
PRINT 10@ 4
2
OK
PRINT 25.6@ 6.99
The dividend is rounded down to 25,
the divisor to 6, and the quotient to 4.
4
OK
…
…
…
…
……
Remainder operations are expressed using the operator MOD and gives the
remainder in integer division integer format.
Example
PRINT 15.4 MOD 4
The remainder left after
3
OK
PRINT 25.68 MOD 6.9
The remainder left after
1
OK
dividing 15 by 4 is 3.
dividing 25 by 6 is 1.
…
…
…
…
…
…
…
…
…
…
…
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...