0% found this document useful (0 votes)
164 views9 pages

1ns and 2s Compliment

The document summarizes the key differences between 1's complement and 2's complement representations of binary numbers. 1's complement is obtained by inverting all bits in the number, while 2's complement is obtained by inverting the bits and adding 1. 2's complement is preferred because it represents 0 unambiguously with all zeros, while 1's complement has two representations of 0. 2's complement arithmetic is also simpler as it does not require handling carry bits. The document provides examples of converting numbers to their 1's and 2's complements.

Uploaded by

Kratika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views9 pages

1ns and 2s Compliment

The document summarizes the key differences between 1's complement and 2's complement representations of binary numbers. 1's complement is obtained by inverting all bits in the number, while 2's complement is obtained by inverting the bits and adding 1. 2's complement is preferred because it represents 0 unambiguously with all zeros, while 1's complement has two representations of 0. 2's complement arithmetic is also simpler as it does not require handling carry bits. The document provides examples of converting numbers to their 1's and 2's complements.

Uploaded by

Kratika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

SOS IN Political Science and Management

Jiwaji University Gwalior


MBA (HRD) III

Subject: Computer Applications 301

Topic: Introduction to 1ns and 2s Compliments

From: Ms. Kratika Pradhan

1's Complement vs 2's Complement


One’s complement and two’s complement are two important binary
concepts. Two’s complement is especially important because it allows us to
represent signed numbers in binary, and one’s complement is the interim
step to finding the two’s complement.

One’s Complement
The complement (or opposite) of +5 is −5. When representing
positive and negative numbers in 8-bit ones complement binary
form, the positive numbers are the same as in signed binary
notation  i.e. the numbers 0 to +127 are represented as
000000002 to 011111112. However, the complement of these
numbers, that is their negative counterparts from −127 to −0, are
represented by ‘complementing’ each 1 bit of the positive binary
number to 0 and each 0 to 1.

For example:

+510 is 000001012

−510 is 111110102

Notice in the above example, that the most significant bit (msb) in
the negative number −510 is 1, just as in signed binary. The
remaining 7 bits of the negative number however are not the same
as in signed binary notation. They are just the complement of the
remaining 7 bits, and these give the value or magnitude of the
number.

If all bits in a byte are inverted by changing each 1 to 0 and each 0 to 1, we


have formed the one’s complement of the number.
Original One's Complement
-------------------------------
10011001  -->  01100110
10000001  -->  01111110
11110000  -->  00001111
11111111  -->  00000000
00000000  -->  11111111
Converting to one’s complement.

And that is all there is to it! One’s complement is useful for forming the two’s
complement of a number.

Two’s Complement (Binary Additive Inverse)

The two’s complement is a method for representing positive and negative


integer values in binary. The useful part of two’s complement is that it
automatically includes the sign bit.

Rule: To form the two’s complement, add 1 to the one’s complement.


Step 1: Begin with the original binary value

    10011001  Original byte

Step 2: Find the one's complement

    01100110  One's complement

Step 3: Add 1 to the one's complement

    01100110  One's complement


  +        1  Add 1
 -----------
    01100111  <---  Two's complement
Converting to two’s complement.

Complements are used in the digital computers in order to simplify the subtraction
operation and for the logical manipulations. For each radix-r system (radix r
represents base of number system) there are two types of complements.

S.N Complement Description


.

1 Radix Complement The radix complement is referred to as the r's


complement

2 Diminished Radix The diminished radix complement is referred to as


Complement the (r-1)'s complement

Binary system complements


As the binary system has base r = 2. So the two types of complements for the
binary system are 2's complement and 1's complement.

1's complement

The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's.
This is called as taking complement or 1's complement. Example of 1's
Complement is as follows.

2's complement

The 2's complement of binary number is obtained by adding 1 to the Least


Significant Bit (LSB) of 1's complement of the number.
2's complement = 1's complement + 1
Example of 2's Complement is as follows.
Complements are used in digital computers in order to simply the subtraction
operation and for the logical manipulations. For the Binary number (base-2) system,
there are two types of complements: 1’s complement and 2’s complement.

1’s Complement of a Binary Number


There is a simple algorithm to convert a binary number into 1’s complement. To get
1’s complement of a binary number, simply invert the given number.

2’s Complement of a Binary Number


There is a simple algorithm to convert a binary number into 2’s complement. To get
2’s complement of a binary number, simply invert the given number and add 1 to the
least significant bit (LSB) of given result.

Differences between 1’s complement and 2’s complement


These differences are given as following below −

1’s complement 2’s complement

To get 1’s complement of a binary number, To get 2’s complement of a binary number,
simply invert the given number. simply invert the given number and add 1 to
the least significant bit (LSB) of given result.

1’s complement of binary number 110010 is 2’s complement of binary number 110010 is
001101 001110

Simple implementation which uses only Uses NOT gate along with full adder for
NOT gates for each input bit. each input bit.

Can be used for signed binary number Can be used for signed binary number
representation but not suitable as representation and most suitable as
ambiguous representation for number 0. unambiguous representation for all
numbers.

0 has two different representation one is -0 0 has only one representation for -0 and +0
(e.g., 1 1111 in five bit register) and second (e.g., 0 0000 in five bit register). Zero (0) is
is +0 (e.g., 0 0000 in five bit register). considered as always positive (sign bit is 0)

For k bits register, positive largest number For k bits register, positive largest number
that can be stored is (2(k-1)-1)  and negative that can be stored is (2(k-1)-1) and negative
lowest number that can be stored is -(2(k-1)-1). lowest number that can be stored is -(2(k-1)).

end-around-carry-bit addition occurs in 1’s end-around-carry-bit addition does not


1’s complement 2’s complement

complement arithmetic operations. It added occur in 2’s complement arithmetic


to the LSB of result. operations. It is ignored.

1’s complement arithmetic operations are 2’s complement arithmetic operations are
not easier than 2’s complement because of much easier than 1’s complement because
addition of end-around-carry-bit. of there is no addition of end-around-carry-
bit.

Sign extension is used for converting a Sign extension is used for converting a
signed integer from one size to another. signed integer from one size to another.

What’s difference between 1’s Complement and


2’s Complement?
1’s complement of a binary number is another binary number obtained by
toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0.
Examples:
Let numbers be stored using 4 bits

1's complement of 7 (0111) is 8 (1000)


1's complement of 12 (1100) is 3 (0011)
2’s complement of a binary number is 1 added to the 1’s complement of the
binary number.
Examples:
Let numbers be stored using 4 bits

2's complement of 7 (0111) is 9 (1001)


2's complement of 12 (1100) is 4 (0100)
The main difference between 1′ s complement and 2′ s complement is that 1′ s
complement has two representations of 0 (zero) – 00000000, which is positive
zero (+0) and 11111111, which is negative zero (-0); whereas in 2′ s
complement, there is only one representation for zero – 00000000 (+0) because
if we add 1 to 11111111 (-1), we get 00000000 (+0) which is the same as positive
zero. This is the reason why 2′ s complement is generally used.

Another difference is that while adding numbers using 1′ s complement, we first


do binary addition, then add in an end-around carry value. But, 2′ s complement
has only one value for zero, and doesn’t require carry values.

Practice

Convert to one’s complement:


1. 1010
2. 11110000
3. 10111100 11000000
4. 10100001
Convert to two’s complement:
1. 1010
2. 11110000
3. 10000000
4. 011111111

Answers

One’s complement:
1. 0101
2. 00001111
3. 01000011 00111111
4. 01011110
Two’s complement:
1. 0110 (1010 –> 0101 + 1 = 0110)
2. 00010000
3. 10000000 (Result is the same as the original value.)
4. 10000001

You might also like