Phần bù 1 và phần bù 2

There are 2 types of binary complements, “1’s complement” and “2’s complement.”

1’s complement

The “1’s complement” of a given numeric value will be the result of the subtraction of each of

the digits of this numeric value from 1, as a result, all the “0” and “1” bits of the original bit

string are switched.

For example, the “1’s complement” of the bit string (10110011)2 is shown below:

1 0 1 1 0 0 1 1

↓ ← All the “0” and “1” bits of the original bit string are switched

0 1 0 0 1 1 0 0 “1’s complement”

2’s complement

“2’s complement” is the “1’s complement” bit string plus 1. Therefore, the “2’s complement” of

the bit string (10110011)2 is obtained as follows:

1 0 1 1 0 0 1 1

↓ ← All the “0” and “1” bits of the original bit string are switched

0 1 0 0 1 1 0 0 “1’s complement”+ 1

1 is added

0 1 0 0 1 1 0 1 “2’s complement”

􀁺 “1’s complement” and “2’s complement” representation of negative integers

“1’s complement” representation of negative integers

Sign bit: 0 for positive, 1 for negative, and both, +0 and -0, for 0

Numeric value: “1’s complement”

For example, the “1’s complement” representation of the decimal number -126 will be as follows:

0 1 1 1 1 1 1 0 + 126

Sign → ↓ ↓ ← All the “0” and “1” bits of the original bit string are switched

1 0 0 0 0 0 0 1 ← −126

“2’s complement” representation of negative integers

Sign bit: 0 for positive and 0, 1 for negative

Numeric value: “2’s complement”

For example, the “2’s complement” representation of the decimal number -126 will be as follows:

0 1 1 1 1 1 1 0 + 126Sign → ↓ ↓ ← All the “0” and “1” bits of the original bit string are switched

1 0 0 0 0 0 0 1

+ 1 1 is added1 0 0 0 0 0 1 0

← −126

As can be observed, even for the same number the bit strings of the “1’s complement” and the “2’s

complement” differ.

Figure 1-1-13 shows a comparison of the range of numeric values which can be represented with 3

bits in the “1’s complement” and the “2’s complement” representation. From this Figure it can be

noted that the range of representable numeric values with the “2’s complement” is wider. Likewise,

as in the absolute value representation of negative integers, and in the representation of negative

numbers using the “1’s complement,” 0 can be represented both, as +0 and as -0, so the operation

becomes complicated. For that reason, a great number of today’s computers have adopted the 2’s

complement method.

Gửi phản hồi

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Log Out / Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Log Out / Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Log Out / Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Log Out / Thay đổi )

Connecting to %s

%d bloggers like this: