Omron CS1G/H-CPUxx-EV1 Programming Manual page 68

Sysmac cs series; sysmac cj series
Hide thumbs Also See for CS1G/H-CPUxx-EV1:
Table of Contents

Advertisement

Basic Concepts
32
True number
−)
+)
Two's complement
Complements
Generally the complement of base x refers to a number produced when all
digits of a given number are subtracted from x – 1 and then 1 is added to the
rightmost digit. (Example: The ten's complement of 7556 is 9999 – 7556 + 1 =
2444.) A complement is used to express a subtraction and other functions as
an addition.
Example: With 8954 – 7556 = 1398, 8954 + (the ten's complement of 7556) =
8954 + 2444 = 11398. If we ignore the leftmost bit, we get a subtraction result
of 1398.
Two's Complements
A two's complement is a base-two complement. Here, we subtract all digits
from 1 (2 – 1 = 1) and add one.
Example: The two's complement of binary number 1101 is 1111 (F Hex) –
1101 (D Hex) + 1 (1 Hex) = 0011 (3 Hex). The following shows this value
expressed in 4-digit hexadecimal.
The two's complement b Hex of a Hex is FFFF Hex – a Hex + 0001 Hex =
b Hex. To determine the two's complement b Hex of "a Hex," use b Hex =
10000 Hex – a Hex.
Example: to determine the two's complement of 3039 Hex, use 10000 Hex –
3039 Hex = CFC7 Hex.
Similarly use a Hex = 10000 Hex – b Hex to determine the value a Hex from
the two's complement b Hex.
Example: To determine the real value from the two's complement CFC7 Hex
use 10000 Hex – CFC7 Hex = 3039 Hex.
The CS/CJ Series has two instructions: NEG(160)(2'S COMPLEMENT) and
NEGL(161) (DOUBLE 2'S COMPLEMENT) that can be used to determine the
two's complement from the true number or to determine the true number from
the two's complement.
Signed BCD Data
Signed BCD data is a special data format that is used to express negative
numbers in BCD. Although this format is found in applications, it is not strictly
defined and depends on the specific application. The CS/CJ Series supports
the following instructions to convert the data formats: SIGNED BCD-TO-
BINARY: BINS(470), DOUBLE SIGNED BCD-TO-BINARY: BISL(472),
F
F
F
1111
1111
1111
0
0
1
0000
0000
0001
F
F
E
1111
1111
1110
0
0
0
0000
0000
0000
F
F
E
1111
1111
1110
Section 2-1
F
1111
3
0011
C
1100
1
0001
D
1101

Advertisement

Table of Contents
loading

Table of Contents