2 Instruction Descriptions
2-222
NJ-series Instructions Reference Manual (W502)
The data type of data format number Format is enumerated type _eBCD_FORMAT. Select one of the
following: _BCD0, _BCD1, _BCD2, or _BCD3. The sign specification in the upper four bits of In
depends on the BCD format number. The data format examples shown below use WORD data for In.
The same sizes of data types are used for In and Out. The valid ranges depend on the value of Format,
as shown below.
The following example is for when In is WORD#2#1011_0100_0101_0010 and Format is _BCD1.
Value of Format
_BCD0 _BCD1 _BCD2 _BCD3
Data
type of
In
↓
Data
type of
Out
BYTE
↓
SINT
−9 to 9 −79 to 79 −9 to 99 −19 to 99
WORD
↓
INT
−999 to 999 −7999 to 7999 −999 to 9999 −1999 to 9999
DWORD
↓
DINT
−9999999 to 9999999 −79999999 to
79999999
−9999999 to 99999999 −19999999 to
99999999
LWORD
↓
LINT
−999999999999999 to
999999999999999
−7999999999999999 to
7999999999999999
−999999999999999 to
9999999999999999
−1999999999999999 to
9999999999999999
Format = _BCD0
Valid range of In: −999 to 999 (BCD)
Format = _BCD2
Valid range of In: −999 to 9999 (BCD)
Format = _BCD1
Valid range of In: −7999 to 7999 (BCD)
Format = _BCD3
Valid range of In: −1999 to 9999 (BCD)
3 BCD digits (12 bits)
3 BCD digits (12 bits)
3 BCD digits (12 bits)
3 BCD digits (12 bits)
#0 to #9: BCD digit 4 (positive)
#A: Negative, BCD digit 4 is 1
#F: Negative, BCD digit 4 is 0
(#B to #E: error)
Sign bit
#0 to #9: BCD digit 4 (positive)
#F: Negative
(#A to #E: error)
0: Positive
Sign bit
0: Positive
1: Negative
1: Negative
BCD digit 4 (three bits: 12 to 14)
15 1211 8 7 4 3 0 15 1211 8 7 4 3 0
In
In
In
In
15 1211 8 7 4 3 0
15 1211 8 7 4 3 0
abc:=BCDsToBin(WORD#2#1011_0100_0101_0010,
_BCD1);
LD
ST
abc
_BCD1
WORD#2#1011_0100_0101_0010
BCDsToBin
EN ENO
In
Format
WORD#2#1011_0100_0101_0010
-3452
In
Out=abc
WORD BCD data
INT data