2 Instruction Descriptions
2-250
NJ-series Instructions Reference Manual (W502)
Conversion is performed using the following procedure.
1
The fractional part of the value of In is rounded off to the closest integer as described below.
2
The resulting integer is taken as an unsigned integer and output as a bit string.
The following table shows how values are rounded.
The following table gives some conversion examples.
The following table shows the valid ranges for In and Out according to their data types.
To convert a bit string to a real number, use a **_TO_*** (Bit String-to-Real Number Conversion Group)
instruction (page 2-244).
• Always use the correct instruction name for the data types of In and Out.
• If the conversion result exceeds the valid range of Out, Out will contain an illegal value.
Value of
fractional
part
Treatment Examples
Less than
0.5
The fractional part is truncated. 1.49 → 1
−1.49 → −1
0.5 If the ones digit is an even number, the fractional part
is truncated. If it is an odd number, the value is
rounded up.
1.50 → 2
2.50 → 2
−1.50 → −2
−2.50 → −2
Greater
than 0.5
The fractional part is rounded up. 1.51 → 2
−1.51 → −2
Value of
In
Integer
Value of
Out
1.6 2 16#0002
3.5 4 16#0004
−1.6 −2 16#FFFE
Data
type of In
Data type
of Out
Valid range for In Valid range for Out
REAL
BYTE −1.285999e+2 to 1.274999e+2 16#00 to 16#FF
WORD −3.276859e+4 to 3.276749e+4 16#0000 to 16#FFFF
DWORD −2.147483e+9 to 2.147483e+9 16#0000_0000 to 16#FFFF_FFFF
LWORD −9.223372e+18 to 9.223372e+18 16#0000_0000_0000_0000 to
16#FFFF_FFEE_FFFF_FFFF
LREAL
BYTE −1.28599999999999e+2 to
1.27499999999999e+2
16#00 to 16#FF
WORD −3.27685999999999e+4 to
3.27674999999999e+4
16#0000 to 16#FFFF
DWORD −2.14748364859999e+9 to
2.14748364749999e+9
16#0000_0000 to 16#FFFF_FFFF
LWORD −9.22337203685477e+18 to
9.22337203685477e+18
16#0000_0000_0000_0000 to
16#FFFF_FFFF_FFFF_FFFF
Additional Information
Precautions for Correct Use
LREAL data DWORD data
In
Out=abc
LREAL#6.5536e+4
16#0001_0000