0% found this document useful (0 votes)
18 views7 pages

DLLec3b Notes

The document discusses binary arithmetic operations that are essential for understanding digital systems and computers. It covers binary addition, subtraction, multiplication, and division. It also covers signed binary numbers using 1's complement and 2's complement representations to allow for positive and negative values. The key binary arithmetic operations of addition, subtraction, and their application to signed numbers are described. Proper handling of overflow during addition is also discussed.

Uploaded by

Chintan Mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

DLLec3b Notes

The document discusses binary arithmetic operations that are essential for understanding digital systems and computers. It covers binary addition, subtraction, multiplication, and division. It also covers signed binary numbers using 1's complement and 2's complement representations to allow for positive and negative values. The key binary arithmetic operations of addition, subtraction, and their application to signed numbers are described. Proper handling of overflow during addition is also discussed.

Uploaded by

Chintan Mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Lecture 3b

Digital Logic - Binary Arithmetic


Chintan Kr Mandal

Why Binary Arithmetic ??? [1]


• Binary arithmetic is essential in all digital computers and in many other types of digital systems.
• To understand digital systems, one must know the basics of binary addition, subtraction, multiplication and division.
• We discuss the various mathematical operations in Binary System.

1 Basic Arithmetic Operations


1.1 Binary Addition
Basic Rules for Addition

0+0=0 Sum of 0 with a carry of 0


0+1=1 Sum of 1 with a carry of 0
1+0=1 Sum of 1 with a carry of 0
1 + 1 = 10 Sum of 0 with a carry of 1

Binary Addition with a Carry of 1 : When there is a carry of 1, a situation arises in which three bits are being added
(a bit in each of the two numbers and a carry bit)

1 + 0 + 0 = 01 Sum of 1 with a carry of 0


1 + 0 + 1 = 10 Sum of 0 with a carry of 1
1 + 1 + 0 = 10 Sum of 0 with a carry of 1
1 + 1 + 1 = 11 Sum of 1 with a carry of 1

1.2 Binary Subtraction


Basic Rules of Subtraction

0-0=0
1-1=0
1-0=1
10 - 1 = 1 0 - 1 with a borrow of 1

Subtraction with a Borrow

Figure 1: Beginning subtraction with the right column

1
1.3 Binary Multiplication
Basic Rules of Multiplication

0×0=0
0×1=0
1×0=0
1×1=1

• Multiplication is performed with binary numbers in the same manner as with decimal numbers.
• It involves forming partial products by
1. shifting each successive partial product left one place
2. adding all the partial product.

1.4 Binary Division

Division Division in binary follows the same procedure as division in decimal

2 Signed Numbers
• In general, there are two types of complements for each base-r system [2]
1. the radix complement (r’s complement)
2. the diminished radix complement. ((r-1)’s complement)
• The complement of a binary number is important because they permit the representation of negative numbers.
• There are the 1’s complement and 2’s complement of binary number
• The method of 2’s complement arithmetic is commonly used in computers to handle negative numbers.
• Other than the complement form, there also exists Sign Magnitude Form

2.1 Binary Sign Magnitude Form


Sign Magnitude Form [1]

The Sign Bit : The left-most bit in a signed binary number is the sign bit, which reflects whether the number is
positive or negative.
A 0 is for positive
A 1 is for negative

• When a signed binary number is represented in sign-magnitude, the left-most bit is the sign bit and the remaining bits
are the magnitude bits.
• The magnitude bits are in true (uncomplemented) binary for both positive and negative numbers.

2
E.g. The decimal number +25 is expressed as an 8-bit signed binary number is
The decimal number -25 is expressed as 10011001

In the sign-magnitude form, a negative number has the same magnitude bits as the corresponding positive
number but the sign bit is a 1 rather than a 0

2.2 The 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

For Decimal numbers : r = 10 and r − 1 = 10 − 1 = 9


9’s Complement : (10n − 1) − N

10n represents a number that consists of a single 1 followed by n 0’s


Therefore, 10n − 1 is a number represented by n 9’s
E.g. The 9’s complement of 546700 is 999999 − 546700 = 453299
E.g. The 9’s complement of 012398 is 999999 − 012398 = 987601

The 1’s Complement :


For binary numbers : r = 2 and r − 1 = 2 − 1 = 1

1’s Complement : (2n − 1) − N , where N is a binary number


* 2n represents a number that consists of a single 1 followed by n 0’s
Therefore, 2n − 1 is a number represented by n 1’s

E.g. If n = 4, we have 24 = (10000)2 and 24 − 1 = (1111)2


** Thus the 1’s complement of a binary number is obtained by subtracting each digit from 1.

** When subtracting from each digir from 1, we can have either 1 − 0 = 1 or 1 − 1 = 0, which causes a bit to change from 0 to 1 or
from 1 to 0

E.g. The 1’s complement of 1011000 is 1111111 − 1011000 = 0100111

E.g. The 1’s complement of 0101101 is 1111111 − 0101101 = 1010010

In the 1’s complement form, a negative number is the 1’s complement of the corresponding positive number.

The (r − 1)’s complement of octal or hexadecimal numbers is obtained by subtracting each digit from 7 or F (decimal
15), respectively
Determine the decimal values of the signed binary numbers expressed in 1’s complement:
(a) 00010111
(b) 11101000

3
2.3 The Radix Complement : (r’s complement)
The r’s complement of an n-digit number N in base r is defined as rn − N for N 6= 0 and 0 for N = 0
Comparing with the (r − 1)’s complement, the r’s complement is obtained by adding 1 to the (r − 1)’s complement i.e.

[(rn − 1) − N ] + 1 = rn − N

10’s Complement :
• The 10’s complement of Decimal 2389 is 7610 + 1 = 7611, which is obtained by adding 1 to the 9’s complement.

• Since 10n is a number represented by a 1 followed by n 0’s, 10n − N can be formed by


1. Leave all least significant 0’s unchanged
2. Subtract the first non-zero least significant digit from 10
3. Consequently, subtract all higher significant digits from 9

E.g. The 10’s complement of 012398 is 987602


E.g. The 10’s complement 0f 246700 is 753300
The 2’s Complement
The 2’s complement can be formed as

1. Leave all least significant 0’s


2. Leave the first 1 unchanged
3. Replace all successive 1’s with 0’s and 0’s with 1’s in all other higher significant digits

E.g. The 2’s complement of 1101100 is 0010100


E.g. The 2’s complement of 0110111 is 1001001
In the 2’s complement form, a negative number is the 2’s complement of the corresponding positive number.

Note : If the original number N contains a radix point, the point should be removed temporarily in order to form the
r’s or (r − 1)’s complement.
Determine the decimal values of the signed binary numbers expressed in 2’s complement:
(a) 01010110
(b) 10101010

4
3 Arithmetic Operations with Signed Numbers
3.1 Addition
• The two numbers in an addition are the addend and the augend
• The result is the sum
• There are four cases that can occur when two signed binary numbers are added
1. Both numbers are positive
2. Positive number with magnitude larger than negative number
3. Negative number with magnitude larger than positive number
4. Both numbers are negative.
Case 1: Both numbers are positive

Figure 2: The sum is positive and is therefore in true (uncomplemented) binary

Case 2: Positive number with magnitude larger than negative number

Figure 3: The final carry bit is discarded.The sum is positive and therefore in true (uncomplemented) binary

Case 3: Negative number with magnitude larger than positive number

Figure 4: The sum is negative and therefore in 2’s complement form

Case 4: Both numbers are negative


Problem : Overflow
when two numbers are added and the number of bits required to represent the sum exceeds the number of bits in the two
numbers, and overflow results as indicated by an incorrect sign bit.

5
Figure 5: The final carry bit is discarded.The sum is negative and therefore in 2’s complement form.

Figure 6:
The sum of 183 requires eight magnitude bits.
Since there are seven magnitude bits in the numbers (one bit is the sign), there is a carry into the sign bit which produces
the overflow indication.

3.2 Subtraction
Subtraction
• Subtraction is a special case of addition.
• Subtracting the subtrahend from the minuend is equivalent to adding the negative-subtrahend and the minuend
E.g. Subtracting +6 (subtrahend) from +9 (minuend) is adding -6 to +9

* The subtraction operation changes the sign of the subtrahend and adds it to the minuend.
• The result is the difference.
The sign of a positive or negative binary number is changed by taking its 2’s complement
subtract two signed numbers (1) Take the 2’s complement of the subtrahend and add.
(2) Discard any final carry bit.
Perform each of the following subtractions of the signed numbers
(a) 00001000 - 00000011
(b) 00001100 - 11110111
(c) 11100111 - 00010011
(d) 10001000 - 11100010

Solutions !!

6
References

References
[1] Thomas L. Floyd. Digital Fundamentals, 8th edition. Pearson Education Inc., 2003.

[2] Morris M. Mano. Digital Design. Pearson Education Inc., 2003.

You might also like