2 Instruction Descriptions
2-284
NJ-series Instructions Reference Manual (W502)
z Round
The Round instruction rounds the number at the first decimal digit. The following table shows how
values are rounded.
z RoundUp
The RoundUp instruction rounds up the number at the first decimal digit.
The differences in these three instructions are shown by the following examples.
The following example for the TRUNC instruction is for when In is REAL#−3.55. The value of vari-
able abc will be DINT#−3.
If the data type of In is REAL, the data type of Out is DINT. If the data type of In is LREAL, the data type
of Out is LINT.
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
Input value
Output value
TRUNC Round RoundUp
REAL#1.6 DINT#1 DINT#2 DINT#2
REAL#1.5 DINT#1 DINT#2 DINT#2
REAL#1.5 DINT#1 DINT#1 DINT#2
REAL#2.5 DINT#2 DINT#2 DINT#3
REAL#-1.6 DINT#-1 DINT#-2 DINT#-2
REAL#-1.5 DINT#-1 DINT#-2 DINT#-2
REAL#-1.4 DINT#-1 DINT#-1 DINT#-2
REAL#-2.5 DINT#-2 DINT#-2 DINT#-3
Additional Information
Precautions for Correct Use
abc:=TRUNC(REAL#-3.55);
LD ST
abc
REAL#-3.55
TRUNC
EN ENO
In