1 Data Representation - L8 - Negative Numbers in Binary

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Chapter 1 : Data Representation

Signed binary numbers

8 Number System
Previously we Learned

• Binary arithmetic
• 1’s complement
• 2’s complement
LESSON OBJECTIVE

• Understanding why 2’s


Signed binary complement are used to
numbers represent the negative
numbers.

KEYWORDS
SUCCESS CRITERIA
• Complement
• Sign bit • Able to represent negative
number in vinary form.
• MSB
Negative binary numbers
• We represent negative binary numbers using a minus
symbol in front of them. In computer number
representation, these numbers can be distinguishable with
the help of an extra bit or flag called sign bit or sign flag in
the Binary number representation system for signed
numbers.

• This extra bit is called sign bit or sign flag which has a
value of sign bit is 0 for positive numbers and 1 for negative
binary numbers.
Ways to represent magnitudes

There are tthree ways to represent signed binary


number:
1. Sign-Magnitude method,
2. 1’s Complement method, and
3. 2’s complement method.
1. Signed Magnitude Method

We only add an extra sign bit at the MSB to


recognize negative and positive numbers.

Sign bit has


• 1 for negative number and
• 0 for positive number.
Signed binary numbers
• For signed binary numbers the most significant bit (MSB) is
used as the sign bit.

• If the sign bit is “0”, this means the number is positive in


value.

• If the sign bit is “1”, then the number is negative in value.

• The remaining bits in the number are used to represent the


magnitude of the binary number in the usual unsigned binary
number format way.
• Then we can see that the Sign-and-Magnitude
(SM) notation stores positive and negative
values by dividing the “n” total bits into two
parts:
– 1 bit for the sign and
– n–1 bits for the value which is a pure binary
number.
• For example, the decimal number 53 can be
expressed as an 8-bit signed binary number as
follows.

Positive Signed Binary Numbers Negative Signed Binary Numbers


2’s Complement Method
• Please note that MSB is always Sign bit, if it 0,
then there are no changes.
• MSB is always 1 in case of negative numbers.
• We only take 2’s complement of negative
numbers to represent in the computer.
MSB is
the
sign bit If the sign bit is “0”, this means the number is positive in value.

8 4 2 1
0 0 0 0 0
+ 5 = 0 101
0 0 0 1 1
0 0 1 0 2
+ 7 = 0 111
0 0 1 1 3
0 1 0 0 4 + 3 = 0 011
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
MSB is
the
sign bit If the sign bit is “1”, this means the number is negative in value.

8 4 2 1
1 0 0 0 -0
- 5 = 1 101
1 0 0 1 -1
1 0 1 0 -2
- 7 = 1 111
1 0 1 1 -3
1 1 0 0 -4 - 3 = 1 011
1 1 0 1 -5
1 1 1 0 -6
1 1 1 1 -7
8 4 2 1
1 1 1 1 -7
1 1 1 0 -6
1 1 0 1 -5
1 1 0 0 -4
1 0 1 1 -3
1 0 1 0 -2
1 0 0 1 -1
1 0 0 0 -0
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
8 4 2 1
1 0 0 1 -7
Use 2’s complement to represent the negative numbers
1 0 1 0 -6
1 0 1 1 -5
1 1 0 0 -4
1 1 0 1 -3
1 1 1 0 -2
1 1 1 1 -1
01 0 0 0 -0
0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
PLENARY

• Represent the decimal number -25, +25 in


signed magnitude and 2’s complement
representation.
• Represent the decimal number -87, +87 in
signed magnitude and 2’s complement
representation.

Evaluation Worksheet
3! 2! 1!

1.

3 Things I 2.
learned
3.

1.
2 Interesting
2.
facts

1 Question
1.

You might also like