0% found this document useful (0 votes)
3 views

DLD Lecture 2

The document covers digital logic design, focusing on arithmetic operations including addition, subtraction, multiplication, and division in binary systems. It explains signed and unsigned binary numbers, along with the concepts of complements, specifically one’s and two’s complements for representing negative numbers. Additionally, it provides examples and methods for performing these operations and representations in binary format.

Uploaded by

f2024-0778
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

DLD Lecture 2

The document covers digital logic design, focusing on arithmetic operations including addition, subtraction, multiplication, and division in binary systems. It explains signed and unsigned binary numbers, along with the concepts of complements, specifically one’s and two’s complements for representing negative numbers. Additionally, it provides examples and methods for performing these operations and representations in binary format.

Uploaded by

f2024-0778
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

CSC 119:Digital Logic Design

Digital Systems and Binary Numbers

Ms. Arooma Amir


Beaconhouse National University, Lahore
Lecture 2
Arithmetic Operations

Addition
Decimal Addition
1 1 Carry
5 5
+ 5 5

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.

Note: multiple carries are possible.


Binary Multiplication:
1 1 0 0
1 0 1 0
0 0 0 0

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

Base Problem Largest Single Digit

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.

 This type of representation does not take the sign


of the binary numbers into consideration while
representing these numbers.
Signed Numbers
 The signed binary numbers are the numbers that are
always associated with a sign. This sign helps in
identifying whether the given binary number is a
positive quantity or a negative quantity.

 Signed-magnitude representation is a method used


in the computer system for representing the signed
binary numbers.
 In this method, an extra bit called sign bit is
associated with the magnitude of the given number.
This sign bit is used to indicate whether the given
binary number is positive or negative. The value of
the sign bit is 0 for the positive numbers and 1 for the
negative numbers.
Signed Binary Numbers
 To represent negative integers, we need a notation for negative
values.
 It is customary to represent the sign with a bit placed in the
leftmost position of the number since binary digits.
 The convention is to make the sign bit 0 for positive and 1 for
negative.
Signed‐Magnitude Representation
Sign bit

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

– Given a number N in base r having n digits, the (r–1)’s complement of N


is defined as:
(rn –1) – N
 Example for 6-digit decimal numbers:

– 9’s complement is (rn – 1)–N = (106–1)–N = (1000000-1)-N = 999999–N


– 9’s complement of 546700 is 999999–546700 = 453299
 Example for 7-digit binary numbers:

– 1’s complement is (rn – 1) – N = (27–1)–N = ((10000000)2-1)-N=1111111–N


– 1’s complement of 1011000 is 1111111–1011000 = 0100111
 Observation:

– Subtraction from (rn – 1) will never require a borrow


– Diminished radix complement can be computed digit-by-digit
Complements
 1’s Complement (Diminished Radix Complement)
– All ‘0’s become ‘1’s
– All ‘1’s become ‘0’s
Example (10110000)2
 (01001111)2
Complements
The r's complement of an n-digit number N in base r is defined as
rn – N for N ≠ 0 and as 0 for N = 0. Comparing with the (r  1) 's
complement, we note that the r's complement is obtained by adding 1
to the (r  1) 's complement, since rn – N = [(rn  1) – N] + 1.
 Radix Complement
The 10's complement of 012398
is 987602
The 10's complement of 246700
is 753300
 Example: Base-10
The 2's complement of 1101100
is 0010100
The 2's complement of 0110111
is 1001001
 Example: Base-2
Complements
 2’s Complement (Radix Complement)
– Take 1’s complement then add 1
OR – Toggle all bits to the left of the first ‘1’ from the right
Example:
Number:
1’s Comp.:

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.

 The equivalent binary representation of 25 is in byte size is


00011001.
 Now, change all the zeros to ones and all the ones to zeros
in order to obtain the ones complement representation:
11100110
 Therefore, the one’s complement representation of -25 is
11100110.
Two’s Complement
 Two’s complement is the most widely used
method for representing negative numbers in the
computer system.
 The two’s complement of the given integer can be
obtained by adding 1 to the one’s complement of
that number.
 For example, the two’s complement
representation of -15 can be obtained by adding 1
to 11110000, which is the one’s complement
representation of -15. Therefore, the two’s
complement representation of -15 is 11110001.
Two’s Complement
 The two’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 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.

 The equivalent binary representation of 33 in a byte is


00100001.
 Now, change all the zeros to ones and all the ones to zeros
in order to obtain the one’s complement representation:
11011110.
 Add 1 to the 11011110.
 Therefore, the two’s complement representation of -33 is
11011111.
Signed Binary and Compliments
 Example: Although there is only one way to represent +9,
there are three different ways to represent -9 with eight
bits:
Signed Binary Numbers

You might also like