Vous êtes sur la page 1sur 3

Data representation

Representing binary as negative numbers


Nadine S. Simms, Contributor
Good day students, I trust your studies have been going well. In today's lesson we
will be continuing the topic of data representation with the focus being on
representing binary as negative numbers.
representing binary as negative numbers
The three most common ways of coding negative numbers on computers are as
follows:
Sign and magnitude
One's complement
Two's complement
Sign and Magnitude
In this coding, one bit represents the sign and the other bit represents the
magnitude of the number. The convention for the sign bit is that the number one (1)
represents negative and the number zero (0) represents positive.
Examples:
Find the sign and magnitude representation of the following numbers:
1. nine
To convert this number to sign and magnitude one must first change the number
into binary (discussed in lesson #12).
910= 10012
Because the number is positive, the sign is represented as zero (0).
The answer is therefore written:
9 = 0(sign): 1001(magnitude)

2. -89
Changing the positive number into binary
8910 = 10110012

Because the number is negative, the sign is represented as one (1).


Therefore the answer is written: -89 = 1(sign): 10110012(magnitude)
one's and two's complement
The main reason for using two's complement and one's complement for the negative
numbers is that they enable subtraction to be performed through a modified form of
addition and thereby simplifies the processing circuit in the chips which do arithmetic
in the computer.
One's complement
In finding one's complement the bits are flipped (i.e. 0 replaces 1 and vice versa)
Example:
1). 1101102 when flipped we get: 0010012.
Two's Complement
The two's complement is found by flipping the bits (as in one's complement) and
then adding one to the result.
Examples:
1). 110011012 = 0010012. (One's complement)
+1
00100112 (Two's Complement)
2). Calculate six minus three (6-3) using twos complement.
Steps to take in answering this question:
1. Convert 6 to binary = 0110
2. Convert 3 to binary = 0011The two's complement of (3) is therefore 1100
+ 1 = 1101 same as (-3)
3. Add the numbers six (6) and negative three (-3):
0110 + 1101 = 100112
The number needs to be represented using 4 bits therefore the answer is written:
0011
This topic can be a bit difficult, so re-read the above notes as often as needed. When
you think you have a good grasp of the concept try answering the following
questions:

Questions:
1).Find the sign and magnitude representation of the following:
a) 45
b) -96
2). Find the two's complement of the following:
a) 1001001
b) -48
3). Calculate the following using two's complement:
a) 7-6
b) 8-5
After having tried them for yourself, but not before, check your answers with the
ones at the end of this lesson.
ANSWERS
1) a. 0:1011012
2) a. 01101112
3).a.00012
b.0100002 b.1: 11000002 b.0011
This is the end of today's lesson . See you next week and remember work, not hard,
but very smart.

Vous aimerez peut-être aussi