You are on page 1of 13

Binary Number Representation

b(n) b(n-1) ... b(1) b(0) =


b(n) x 2^n + b(n-1) x 2^(n-1) + ... +
b(1) x 2 ^1 + b(0) x 2^0

Lec 7-1
Decimal-to-Binary Conversion

Example 1: Convert 11 (Base 10) to Unsigned Binary Notation

• Quotient Remainder
11/2 = 5 1
5/2 = 2 1
2/2 = 1 0
1/2 = 0 1
Thus, 11 (Base 10) = 1011 (Base 2)
Lec 7-2
Sign-Magnitude Notation

The simpliest form of representation


that employs a sign bit, the leftmost
significant bit. For an N-bit word,
the rightmost N-1 bits hold the
magnitude of the integer. Thus,

• 00010010 = +18
• 10010010 = -18
Lec 7-3
Drawbacks of Sign-Magnitude
Notation

• Addition and subtraction require a


consideration of both the signs of the
numbers, and their relative
magnitudes, in order to carry out the
requested operation.

• There are two representations for


zero.
Lec 7-4
Ones Complement Notation

• Positive integers are represented in the same way


as sign-magnitude notation. A negative integer is
represented by the 1's complement of the positive
integer in sign-magnitude notation. The ones
complement of a number is obtained by
complementing each one of the bits, i.e., a 1 is
replaced by a 0, and a 0 is replaced by a 1.
• 18 (Base 10) = 00010010
• -18 (Base 10) = 1's complement of 18
= 11101101
Lec 7-5
Twos Complement Notation

• The 2's complement representation of


positive integers is the same as in sign-
magnitude representation.
• A negative number is represented by the
2's complement of the positive integer with
the same magnitude.
1. Perform the 1's complement operation.
2. Treating the result as an unsigned binary
integer, add 1.
Lec 7-6
Twos Complement Example

18 = 00010010
1's complement= 11101101
+1
________
TC of 18 = 11101110 = -18D

Lec 7-7
Binary Addition and Subtration

• The simplest implemention is one in


which the numbers involved can be
treated as unsigned integers for
purposes of addition.
• (=> not sign-magnitude or ones
complement)

Lec 7-8
Ones Complement Addition

ex. 1. ex. 2.
+1 0001 +3 0011
-6 1001 -3 1100
-------- --------
-5 1010 -0 1111

Lec 7-9
Ones Complement End Around
Carry

-2 1101
-4 1011
--------
1)1000
--> 1
--------
1001 = -6
Lec 7-10
Twos Complement Addition

a) 1001 = -7 b) 1100 = -4 c) 0011 = +3

0101 = +5 0100 = +4 0100 = +4


---- ---- ----
1110 = -2 (1)0000 = 0 0111 = +7

• In Twos Complement addition, the


Carry Out of the most significant bit
is ignored! Lec 7-11
Overflow/Underflow

• Overflow (Underflow) occurs whenever


two positive (negative) numbers are added
and the result indicates a negative
(positive) number.
• Stated another way, if 2 numbers are
added, and they are both positive (or both
negative), then overflow (underflow)
occurs if and only if the result has an
opposite sign.

Lec 7-12
Subtraction

• To subtract one number


(subtrahend) from another
(minuend), take the omplementof the
subtrahend and add it to the
minuend.
• If the numbers are ones (twos)
complement numbers, take the ones
(twos) complement of the subtrahend
and add it to the minuend.
Lec 7-13

You might also like