Type Conversion - Mitsubishi QD51 Programming Manual

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

2 THE BASICS OF AD51H-BASIC

2.9 Type Conversion

Value 1
Integer
Integer
Integer
Single-precision real number
Single-precision real number
Double-precision real number
2 - 17
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 2
Integer
Single-precision real number
Double-precision real number
Single-precision real number
Double-precision real number
Double-precision real number
Example
..................
10 D#=6#/7
20 PRINT D#
RUN
.8571428571428571
OK
(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.
(The result is the same when Value 1 and Value 2 are reversed.)
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.
MELSEC-Q
Operation Result
Integer
Single-precision real number
Double-precision real number
Single-precision real number
Double-precision real number
Double-precision real number
2 - 17

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents