Mitsubishi Electric MELSEC iQ-R Series Programming Manual page 65

Hide thumbs Also See for MELSEC iQ-R Series:
Table of Contents

Advertisement

■ Automatic conversion of data type
When assignment or arithmetic operational expressions between different data types is described in ST language, one data
type may be converted automatically.
Ex.
Example of automatic conversion
dintLabel1 := intLabel1;
// Assignment statement: Automatically convert the INT type variable (intLabel1) to a DINT type variable, and assign it to the DINT type variable (dintLabel1).
dintLabel1 := dintLabel2 + intLabel1;
// Arithmetic operational expression: Automatically convert the INT type variable (intLabel1) to a DINT type variable, and perform addition in DINT type.
DMOV(TRUE, wordLabel1, dwordLabel1);
// Instruction, function, and function block call statement: Automatically convert the WORD type input argument (wordLabel1) to a DWORD type variable, and
transfer the data.
Type conversion is performed in assignment statements, VAR_INPUT part where input argument is passed to function blocks
and functions (including instruction, standard functions, and standard function blocks), and arithmetic operational
expressions.
To prevent data from being lost during type conversion, conversion is performed only from a smaller size data type to a larger
size data type. Type conversion is performed for the following data types among the primitive data types.
Data type
Word [signed]
Word [unsigned]/bit string [16 bits]
Double word [signed]
Double word [unsigned]/bit string [32 bits]
Single-precision real number
*1 When 16-bit data (word [signed] or word [unsigned]/bit string [16 bits]) is passed to the input argument of which data type is ANY_REAL,
the data is automatically converted to single-precision real number.
*2 When data (word [unsigned]/bit string [16 bits]) is passed to the input argument of which data type is ANY32, the data is automatically
converted to double word [unsigned]/bit string [32 bits].
For the data types other than the above, use the type conversion functions.
Use the type conversion functions for the following conversions as well.
• Type conversion between integral data types with different signs
• Type conversion between data types both of which lose data
For the precautions on assignment of the arithmetic operation result, refer to the following.
Page 67 When the result of an arithmetic operation is assigned
For the precautions on the use of devices, refer to the following.
Page 73 When performing automatic conversion of data type with devices
Description
When the data type is converted to the double word [signed], the value is automatically sign extended.
When the data type is converted to the single-precision real number or double-precision real number, the value is
automatically converted to the same value as the integer before conversion.
When the data type is converted to the double word [unsigned]/bit string [32 bits] or double word [signed], the
value is automatically zero extended.
When the data type is converted to the single-precision real number or double-precision real number, the value is
automatically converted to the same value as the integer before conversion.
When the data type is converted to the double-precision real number, the value is automatically converted to the
same value as the integer before conversion.
When the data type is converted to the double-precision real number, the value is automatically converted to the
same value.
*2
6 STRUCTURED TEXT LANGUAGE
*1
*1
6.1 Configuration
6
63

Advertisement

Table of Contents
loading

Table of Contents