2-281
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Data Type Conversion Instructions
2
TO_** (Real Number Conversion Group)
TO_** (Real Number Conversion
Group)
These instructions convert integers, bit strings, real numbers, and text strings to real numbers.
*1 The valid ranges depend on the data types of In and Out.
*2 For STRING data, the valid range is 311 bytes max. (310 single-byte alphanumeric characters plus the final NULL charac-
ter).
*3 If you omit the input parameter, the default value is not applied. A building error will occur.
These instructions convert the integer, bit string, real number, or text string in In to a real number.
The name of the instruction is determined by the data type of conversion result Out. For example, if Out
is the REAL data type, the instruction is TO_REAL. If the value of In is positive or negative infinity, the
value of Out is positive or negative infinity.
The following example for the TO_REAL instruction is for when In is INT#1234.
Instruction Name FB/FUN Graphic expression ST expression
TO_** Real Number Con-
version Group
FUN Out:=TO_**(In);
"**" must be a real number
data type.
Variables
Name Meaning I/O Description Valid range Unit Default
In Data to
convert
Input Data to convert
*1, *2
---
*3
Out Conver-
sion result
Output Conversion result
*1
--- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
In OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
Out OK OK
Function
"**" must be a real number data type.
(@)TO_**
EN ENO
In Out
abc:=TO_REAL(INT#1234);
LD ST
abc
INT#1234
TO_REAL
EN ENO
In