0% found this document useful (0 votes)
30 views35 pages

02 Digital Arithmetic

lesson material

Uploaded by

LEBRON JAMES
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)
30 views35 pages

02 Digital Arithmetic

lesson material

Uploaded by

LEBRON JAMES
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/ 35

Internal Use

Digital
Arithmetic
CPE107-4 Logic Circuits and Design
Engr. John Paul T. Cruz
Internal Use

Objectives
• Differentiate unsigned and signed representations of binary numbers.
• Understand the concept of signed numbers.
• Represent numbers in unsigned and signed representations.
• Perform digital arithmetic operations on unsigned and signed numbers.
• Perform addition and subtraction of BCD and Hexadecimal Numbers
Internal Use

Unsigned Binary Arithmetic


Digital systems perform various arithmetic operations on numbers represented in binary
form. These operations are identical to the operations performed on decimal numbers:
Addition, Subtraction, Multiplication, Division

The binary arithmetic operations always start from the least significant bit. These operations
can be done on unsigned and signed numbers. Unsigned numbers are, by definition,
positive numbers and do not require an arithmetic sign.
Internal Use

Binary Addition
There are four basic rules in order to perform binary addition. These rules are listed below:

Notice that the first three rules are quite simple since there is no difference between these
binary rules and the corresponding decimal rules. The fourth rule, however, is different from
decimal. Whenever we add two 1s together in binary, we generate a carry to the next
column since the binary system only has two digits.
Internal Use

Binary Addition

1 0 02
1 1 0.0 1 02
+ 0 0 1.0 1 12
1 1 1.1 0 12
Internal Use

Binary Subtraction
There are four basic rules in order to perform binary subtraction. These rules are listed
below:

Rules 1, 3, and 4 are similar to their decimal counterparts. The second rule, however, uses
the concept of borrowing from another column.
Internal Use

Binary Subtraction

1 1
0 1 0 1 0 0 1 2
1 0 1 0 1.1 0 12
- 0 1 0 1 1.1 1 02
1 0 0 1.1 1 12
Internal Use

Binary Multiplication
Binary multiplication uses the same technique as decimal multiplication. In fact, binary
multiplication is easier because each digit we multiply is either zero or one.

In Binary multiplication, there will be partial products which will be added to obtain the
complete product.
Internal Use

Binary Multiplication

1 0 1 1.0 12
x 1 1 0.12
1 0 1 1 0 12
0 0 0 0 0 0 02
101101 2
101101 2
1 0 0 1 0 0 1.0 0 12
Internal Use

Binary Division
In Binary division, we use the same long division technique in the decimal system.

The rules of binary division are the following:


1. Divide the number using the long division method
2. When the remainder is greater than or equal to the divisor, write 1 in the quotient and
subtract.
3. When the remainder is less than the divisor, write a 0 in the quotient and add another
digit from the dividend.
4. If all the digits of the divided have been considered and there is still a remainder, mark a
binary point in the divided and append a zero. Remember that some fractions do not
have an exact representation in binary, so not all division problems will terminate.
Internal Use

Binary Division

1 0.12
1 0 1 0 1.02
10 2
0 1 02
1 02
02
Internal Use

Signed Binary Arithmetic


In digital systems, binary numbers can be represented in unsigned or signed forms.
Unsigned numbers are positive numbers and do not require an arithmetic sign. Signed
numbers require an arithmetic sign.

The most significant bit of a binary number represents the sign bit. The signed binary
number is positive if the sign bit is equal to zero. Otherwise, it is negative. There are three
ways to represent signed numbers:

1. Sign Magnitude System


2. 1’s Complement Representation
3. 2’s Complement Representation
Internal Use

Sign Magnitude System


The Sign Magnitude System, often called the True Magnitude System, represents a number
in its binary form. The most significant bit represents the sign bit (0 for positive and 1 for
negative). The remaining bits represent the magnitude of the number.
Internal Use

1’s Complement Representation


The 1’s complement of a binary number is obtained by changing each 0 to a 1 and each 1
to a 0. In other words, change each it in the number to its complement. Similar to the Sign
Magnitude System, the MSB represents the sign.
Internal Use

2’s Complement Representation


There are two ways to represent signed numbers in 2’s complement form:
• If the number is positive, the magnitude is represented in its true binary form, and a sign
bit of 0 is placed in front of the MSB.
• If the number is negative, the magnitude is represented in its 2’s complement form, and a
sign bit of 1 is placed in front of the MSB.
Internal Use

2’s Complement Representation


The 2’s complement form of a binary number is formed by taking the 1’s complement of the
binary number and adding 1 to the least significant bit position. The process is illustrated
below:
Internal Use

Sign Extension
Modern digital systems store numbers in even multiples of 4 bits (4, 8, 12, 16, 20, etc.) In a
system that stores 8-bit numbers, the 7-bits represent the magnitude, and the MSB
represents the sign.

For instance, if we need to store a positive 5-bit number in an 8-bit storage location, we
extend the sign.

0000 10012 = 910

The same principle is applied if the number is negative. For instance, if we store a negative
6-bit number in an 8-bit storage location:

1110 01112 = -2510


Internal Use

Signed Binary Arithmetic


Signed Binary Arithmetic is performed using the 2’s complement system. The system can
perform addition and subtraction, wherein mostly addition is performed. There are five
possible cases:

1. Two Positive Numbers


2. Positive Number and Smaller Negative Number
3. Positive Number and Larger Negative Number
4. Two Negative Numbers
5. Equal and Opposite Numbers
Internal Use

Signed Binary Arithmetic


Case 1: Two Positive Numbers
Internal Use

Signed Binary Arithmetic


Case 2: Positive Number and Smaller Negative Number
Internal Use

Signed Binary Arithmetic


Case 3: Positive Number and Larger Negative Number
Internal Use

Signed Binary Arithmetic


Case 4: Two Negative Numbers
Internal Use

Signed Binary Arithmetic


Case 5: Equal and Opposite Numbers
Internal Use

Arithmetic Overflow
An Arithmetic Overflow occurs when there are insufficient bits in a binary number
representation to portray the result of the arithmetic operation. This condition can only occur
when adding two positive or two negative numbers.

An overflow condition can be detected by checking if the sign bit of the result is the same as
the sign bits of the numbers being added.
Internal Use

The Number Circle


Internal Use

The Binary Coded Decimal


BCDs or Binary Coded Decimals are the binary encodings of each decimal number where
each digit is represented by a fixed number of bits (4-bits).

The BCD code does not use 1010, 1011, 1100, 1101, 1110, 1111. In other words, only 10 of
the 16 possible 4-bit binary code groups are used. The radix is BCD (i.e. 100001110100BCD)
Internal Use

BCD Addition
In performing BCD addition, there are two cases to consider: sum is less than or equal to 9,
or sum is greater than 9.

The BCD codes are added using the principle of Binary addition. Since none of the sums
exceed 9, no carries are produced to the next code.
Internal Use

BCD Addition
The BCD codes are added using the principle of Binary addition. Since none of the sums
exceed 9, no carries are produced to the next code.
Internal Use

BCD Subtraction
In performing BCD subtraction, the 9’s complement of the subtrahend must be obtained.
The 9’s complement of any decimal number is obtained by the formula 9 – N, where N is
the Decimal number.

The process of BCD subtraction is:


1. Obtain the 9’s complement form of the subtrahend.
2. Perform binary addition.
3. If the generated result is greater than 9, use the correction factor (0110).
4. If an end around carry is produced, the result is positive and the end around carry must
be added,
5. If no end around carry is produced, the result is negative, and we get the 9’s
complement of the result.
Internal Use

BCD Subtraction
1 1 1
1510 = 0001 0101BCD
- 410 = 1001
1 1
0101
1 1 1 BCD
1110 1 1010 1010
0110 0110
Consider the fact that 410 can be
0001 0000
represented by 0410 when being
added to a 2-digit augend. Obtain the
1
9’s complement of 0 as well. 0001 0001BCD
Internal Use

BCD Subtraction
1 1 1
2310 = 0010 0011BCD
-7210 = 00101 0111
1 1 BCD
-4910 0100 1010
0110
0101 0000

0100 1001BCD
Internal Use

Hexadecimal Addition
The addition of Hexadecimal numbers is done in much the same way as decimal addition if
you remember the hex digit representations of 10-15. The procedure is as follows:

1. Add the two hex digits in decimal, mentally inserting the decimal equivalent for those
digits larger than 9 (A-F).
2. If the sum is less than or equal to 15, it can be directly expressed as a Hex digit.
3. If the sum is greater than or equal to 16, subtract 16 and carry a 1 to the next digit
position.
Internal Use

Hexadecimal Addition

2A3916 3 A F16
9 + 5 = 14 or E
+ 1B516 3 + B = 14 or E + 2 3 C16
A + 1 = 11 or B
2BEE16 5 14 27
-16
Since 27 > 16, subtract 16 to
get 11, which hexadecimal B
11
and carry a 1 to the next
position.
5 E B16
Internal Use

Hexadecimal Subtraction
The process is similar to binary subtraction, but you will borrow 16 from the next digit
instead.

16 16
5 B A16
- 1 F C16
3 B E16
Internal Use

You might also like