DLD Lecture 2
DLD Lecture 2
1 1 0
= Ten ≥ Base
Subtract a Base
Binary Addition
Column Addition
1 1 1 1 1 1
1 1 1 1 0 1 = 61
+ 1 0 1 1 1 = 23
1 0 1 0 1 0 0 = 84
≥ (2)10
Binary Addition:
1010111
+1 0 0 1 0 1 1
111111
1010111
+1 0 0 1 0 1 1
11100010
Binary Addition:
1 1 0 1 1 0 1
+ 1 0 1 1 0
1 1 1 1 1
1 1 0 1 1 0 1
+ 1 0 1 1 0
1 0 0 0 0 0 1 1
Binary Subtraction
Binary Multiplication
1 1 0 1 0
Multiplicand
x 1 0 1 0
Multiplier
1 1 0 1 0 Multiplicand
x 1 0 1 0 Multiplier
0 0 0 0 0
1 1 0 1 0
0 0 0 0 0
1 1 0 1 0
1 0 0 0 0 0 1 0 0 Product
Binary Multiplication
1 1 0 1 1 0 1
x 1 0 0 1 1 0
Binary Multiplication
1 1 0 1 1 0 1
x 1 0 0 1 1 0
2’s place (bits shifted to line
1 1 0 1 1 0 1 up with 2’s place of multiplier)
1 1 0 1 1 0 1
1 1 0 1 1 0 1
Result (AND)
1 0 0 0 0 0 0 1 0 1 1 1 0 Note the 0 at the end, since
the 1’s place is not brought
down.
1 1 0 0
1 0 1 0
0 0 0 0
1 1 0 0
0 0 0 0
1 1 0 0
1 1 1 1 0 0 0
Binary Division
Binary Division
Binary Division:
1 0 1 ) 1 1 0 1 0
1 0 1 Quotient
1 0 1 ) 1 1 0 1 0
1 0 1
0 0 1 1 0
1 0 1
1 Remainder
Addition
6
Decimal +3 9
6
Octal +1 7
6
Hexadecimal +9 F
1
Binary +0 1
Addition
Base Problem Carry Answer
6
Decimal +4 Carry the 10 10
6
Octal +2 Carry the 8 10
6
Hexadecimal +A Carry the 16 10
1
Binary +1 Carry the 2 10
Signed/Unsigned Numbers
Unsigned Numbers
The unsigned binary number is the number with a
magnitude of either zero or greater than zero, and
are usually represented using the unsigned-
magnitude representation, which only represents
the magnitude of the numbers.
0 0 1 1 0 0 1 0 50
Sign bit
1 0 1 1 0 0 1 0 -50
Complements
There are two types of complements for each base-r system: the radix
complement and diminished radix complement.
Diminished Radix Complement - (r-1)’s Complement
10110000 10110000
01001111
+ 1
01010000 01010000
Complements of Binary Numbers
1’s complements
2’s complements
Complements of Binary Numbers
1’scomplement
Change all 1s to 0s and all 0s to 1s
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
Complements of Binary Numbers
2’s complement
Find 1’s complement and then add 1
1 0 1 0 1 0 1 0
1
1’s 0 1 0 1 0 1 0 1
complement Input bits
Carry
Adder (add 1)
In
Output bits (sum)
2’s 0 1 0 1 0 1 1 0
complement
Complements of Binary
Numbers
The complement system can also be used to
represent the signed binary numbers apart from
the signed-magnitude representation method.
In the complement system, the positive integers
are represented in a similar manner as they are
represented in the signed-magnitude
representation. The following are the two most
popular complement methods used in the
computer system:
One’s complement
Two’s complement
One’s Complement
One’s complement method can be used to
represent negative binary numbers.
A negative number can be represented using
one’s complement method by first computing the
binary equivalent of the number and then
changing all the zeros with ones and all the ones
with zeros.
For example, the binary equivalent of the decimal
number 15 is 00001111.
Therefore, -15 can be represented using one’s
complement method as 11110000.
One’s Complement
The one’s complement method also uses the left
most bit as the sign bit to indicate the sign of the
number.
Sign bit
1 1 1 1 0 0 0 0 -15
One’s Complement
Integers One’s complement representation
-7 1000
-6 1001
The one’s
-5 1010
complement method
-4 1011
of representing
-3 1100
signed numbers also
-2 1101
has two different
-1 1110
representations for
-0 1111
the number, zero.
+0 0000
+1 0001
+2 0010
+3 0011
+4 0100
+5 0101
+6 0110
+7 0111
One’s Complement
Example: Represent -25 in the one’s complement
system in byte size.
Sign bit
1 1 1 1 0 0 0 1 -15
Two’s Complement
Integers Two’s complement representation
-7 1001
-6 1010
-5 1011
-4 1100
-3 1101
-2 1110
-1 1111
-0 0000
+0 0000
+1 0001
+2 0010
+3 0011
+4 0100
+5 0101
+6 0110
+7 0111
Two’s Complement
Example : Represent -33 in the two’s complement
system in byte size.