2 Instruction Descriptions
2-156
NJ-series Instructions Reference Manual (W502)
SUB (-)
The SUB (-) instruction subtracts integers and real numbers.
* If you omit an input parameter, the default value is not applied. A building error will occur.
The SUB (-) instruction subtracts subtrahend In2 from minuend In1 and outputs the result. The data
types of In1, In2, and subtraction result Out can have different data types.
The following example is for when In1 is INT#50 and In2 is INT#10. The value of variable abc will be
INT#40.
The functions of the SUB instruction and the - instruction are exactly the same. Use the form that is
easier to use.
Instruction Name
FB/FUN
Graphic expression ST expression
SUB (-) Subtraction FUN Out:=In1 - In2;
Variables
Name Meaning I/O Description Valid range Unit Default
In1 Minuend
Input
Minuend
Depends on data type. --- 0*
In2 Subtrahend Subtrahend
Out Subtrac-
tion result
Output Subtraction result Depends on data type. --- ---
Boolean
Bit string 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
In1 OKOKOKOKOKOKOKOKOKOK
In2 OKOKOKOKOKOKOKOKOKOK
Out OKOKOKOKOKOKOKOKOKOK
Function
(@)SUB
EN ENO
In1 Out
In2
(@)-
EN ENO
In1 Out
In2
abc:=INT#50-INT#10;
LD ST
abc
INT#50
INT#10
SUB
EN ENO
In1
In2