2 - 17 2 - 17
MELSEC-Q
2 THE BASICS OF AD51H-BASIC
2.9 Type Conversion
BASIC changes the type of numeric constants to another type as needed. In this case,
it follows the following rules.
(1) When a numeric constant of a certain type is assigned to a numeric variable of a
different type, the value of the constant will be changed to the type declared in the
variable name and stored. (If a numeric value is assigned to a character string
variable, or vice versa, a “Type mismatch” error will occur.)
Example
10 A% =23.42
20 PRINT A%
RUN
23
OK
(2) If an expression contains different types of numeric constants or numeric
variables, the operation result will be as follows.
• When two values are used for an operation:
Value 1
Value 2
Operation Result
Integer
Integer
Integer
Integer
Single-precision real number
Single-precision real number
Integer
Double-precision real number
Double-precision real number
Single-precision real number
Single-precision real number
Single-precision real number
Single-precision real number
Double-precision real number
Double-precision real number
Double-precision real number
Double-precision real number
Double-precision real number
(The result is the same when Value 1 and Value 2 are reversed.)
Example
10 D#=6#/7
20 PRINT D#
RUN
.8571428571428571
OK
Since double-precision is divided by single-precision here,
the arithmetic operation is performed in double-precision.
The result will be assigned to D# as a double-precision value.
………………
(3) When a logical operation is performed, numeric constants and numeric variables
within the expression are converted to integers before carrying out the operation.
The value must be within the range from –32768 to 32767. An “Overflow” error
will occur if this range is exceeded.
Содержание 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...