You are on page 1of 3

Submitted By: Khwaja Masud Ashraf

Program: BS(SE)
RegNo#: 12226

Q1) What is the difference between signed and


unassigned binary number? How does 2’s complement
works?
Signed binary numbers:
Signed binary numbers means that both positive and negative
numbers may be represented. The most significant bit represents
the sign.
• Three main signed binary number codes are used.
– Sign magnitude
– 2s complement
– 1s complement
2’s complement of binary number N defined as (r n -1)-N+1.
– r is the based
– n is the number of digits

2’s complement
• 2’s complement number is formed by changing 1’s into 0’s and
0’s into 1’s then adding 1.
• 2’s complement of –1010
• +1010=01010
• The 1’s complement 10101
• 2’s complement add 1 to 1’s complement
• 10101+1=10110
• X=-9, Y=+5

Example:
• Find X+Y, Using 2’s complement
Y=0 0101
X=(100000-1)-00101+1=11111-01001+1
X=1 0110+1=1 0111
1 0111
0 0101
1 1100

Unsigned binary numbers:


Unsigned numbers stored only positive numbers but not negative
numbers. Unsigned numbers don’t have any sign, these can contain
only magnitude of the number. So, representation of unsigned
binary numbers are all positive numbers only. For example,
representation of positive decimal numbers are positive by default.
We always assume that there is a positive sign symbol in front of
every number.
The range of unsigned binary number is from 0 to (2n-1).

2’s complement
In 2’s complement representation, we look at the first digit of the
binary number to determine if it is positive or negative. If the
number is position, the number will start with 0. If the number is
negative, the number will start with 1.

Example
Let’s convert 10110110.
Since the most significant bit is 1, we need to flip the digits in the
number.
10110110 → 01001001.
Add 1 to the number. 01001001+1=01001010.
01001010 (binary) = 74 (decimal).
So, 10110110 (2’s complement) =-74 (decimal).

The End

You might also like