0% found this document useful (0 votes)
61 views12 pages

Addition of Hexadecimal Numbers:: Examples

Research

Uploaded by

lilting001
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)
61 views12 pages

Addition of Hexadecimal Numbers:: Examples

Research

Uploaded by

lilting001
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

University of Anbar Subject / Digital TechniquesI

College of Engineering First Stage / 2nd Semester


Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Addition of Hexadecimal Numbers:
Hex numbers are used extensively in machine-language computer
programming and in conjunction with computer memories. When working in these
areas, there will be situations where hex numbers have to be added or subtracted.
The addition can be done in the same manner as decimal addition. Let’s add the
hex numbers 58 and 24, 58 and 4B.

58 3AF 58
+ 24 + 23C + 4B
7C 5EB 93

Examples: add the following hexadecimal numbers.


(a) 23(16)+16(16) (b) 58(16)+22(16) (c) DF(16)+AC(16)

23 right column: 3(16)+6(16) = 3(10)+6(10) = 9(10) = 9(16)


+ 16 left column: 2(16)+1(16) = 2(10)+1(10) = 3(10) = 3(16)
39

58 right column: 8(16)+2(16) = 8(10)+2(10) = 10(10) = A(16)


+ 22 left column: 5(16)+2(16) = 5(10)+2(10) = 7(10) = 7(16)
7A

DF right column: F(16)+C(16) = 15(10)+12(10) = 27(10)


= 27(10)-16(10) = 11(10) = B(16) with a carry of 1
+ AC left column: D(16)+A(16)+1(16)= 13(10)+10(10) +1(10)= 24(10)
18B = 24(10)-16(10) = 8(10) = 8(16) with a carry of 1

Subtraction of Hexadecimal Numbers (Using Direct Method):


Reverse operation of addition may be used as a direct way to subtract
hexadecimal numbers as shown in the following examples:
D3A right column: A(16 )- 4(16) = 10(10) - 4(10) = 6(10) = 6(16)
- F4 middle column: 3(16) - F(16)= 3(10) - 15(10) (need borrow)
C46 = 19(10) - 15(10)= 4(10) =4(16)
left column: D(16) - 1(16) = C(16)

84 right column : 4(16 )- A(16) = 4(10) - 10(10) (need borrow)


- 2A = 20(10) - 10(10)= 10(10) =A(16)
5A left column : 8(16) - 2(16) - 1(16)= 5(16) 1
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

Subtraction of Hexadecimal Numbers (Using Complement Method):


Remember that hex numbers are just an efficient way to represent binary
numbers. Thus we can subtract hex numbers using the same method we used for
binary numbers. In order to find the complement of hex numbers, two ways are
found
 first way: 7 3 A hex number
0111 0011 1010 convert to binary
1000 1100 0101 1’s complement representation
1000 1100 0110 2’s complement representation
8 C 6 conversion back to hex

 Second way: this procedure is quicker, subtract each hex digit from F, and
then add 1. let’s try this for the same hex number from the example above:

F F F
-7 -3 -A Subtract each digit from F
8 C 5
+1 adding 1
8 C 6 hex. Equivalent of 2’s comp.

1- Inverter (NOT Gate):


The inverter performs the operation called inversion or complementation.
The purpose of the inverter is to change the one logic level to the opposite level. In
terms of bits, it changes a 1 to 0 and a 0 to a 1.

Inverter Truth Table

Input ( A ) Logic Symbol


Output ( A )
0 1
A A
1 0

2
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
2- AND Gate:
The AND Gate is one of the basic gates from which all logic functions are
constructed. An AND gate can have two or more inputs and performs what is
known as logical multiplication. Figure below, all possible logic levels for a 2-
input AND gate.

AND Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 0 A
X
0 1 0 B
1 0 0
1 1 1

The total number of possible combinations of binary inputs to a gate is


determined by the following formula:
N = 2n
Where N is the total possible combinations and n is the number of input variables.
To illustrate,
For two input variables: N=22 =4
For three input variables: N=23 =8
For four input variables: N=24 =16

3
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
3- OR Gate:
The OR gate is one of the basic gates from which all logic functions are
constructed. An OR gate can have two or more inputs and performs what is know
as logical addition. Figure below, all possible logic levels for a 2-input OR gate.
OR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 0 A
X
0 1 1 B
1 0 1
1 1 1

4- NAND Gate:
The NAND gate is a popular logic element because it can be used as a
universal gate; that is; NAND gate can be used to perform the AND, OR, and
Inverter operations, or any combination of these operations. The term NAND is a
contraction of NOT-AND and implies an AND function with a complemented
(Inverted) output. Figure below Operation of a 2-input NAND gate.

A A
X X
B B
4
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

NAND Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 1 A
X
0 1 1 B
1 0 1
1 1 0

5- NOR Gate:
The NOR gate, like the NAND gate, is a very useful logic element because it
can also be used as a universal gate; that is; NOR gate can be used to perform the
AND, OR, and Inverter operations, or any combination of these operations.

NOR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 1 A
X
0 1 0 B
1 0 0
1 1 0

5
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
The term NOR is contraction of NOT-OR and implies an OR function with an
inverted output. Figure below Operation of a 2-input NOR gate.

A A
X X
B B

6- Exclusive-OR Gate (XOR):


The Exclusive-OR is actually formed by a combination of other gates.
Figure below, all possible logic levels for an exclusive-OR gate.

XOR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 0 A
X
0 1 1 B
1 0 1
1 1 0

6
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

7- Exclusive-NOR Gate (XNOR):


The Exclusive-NOR is actually formed by a combination of other gates.
Figure below, all possible logic levels for an exclusive-NOR gate.
XNOR Gate Truth Table

Inputs Output
Logic Symbol
A B X
0 0 1 A
X
0 1 0 B
1 0 0
1 1 1

Example: (a) Develop the truth table for a 3-input AND gate.
(b) Determine the total number of possible input combinations for a
5-input AND gate.
For branch (a) there are eight possible input combinations for a 3-input AND gate.

7
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

Input Output
A B C X
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1

For branch (b), N=25 =32. There are 32 possible combinations of input bits for a
5-input AND gate.

Example: for the two input waveforms, A and B, sketch the output waveform,
showing its proper relation to the inputs.

A A
B
B

X
X

When either or both inputs are HIGH, the output is HIGH as shown by the output
waveform X in the timing diagram.

8
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Example: Sketch the output waveform for the 3-input NOR gate, showing the
proper relation to the input.

A A
B
B C

X
X

The output X is LOW when any input is HIGH as shown by the output waveform
X in the timing diagram.

Example: For the 4-input NOR gate operating as a negative-AND. determine the
output relative to the inputs.

A A
B
C
B D

9
X X
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬

Review Questions:
1. When is the output of an AND gate HIGH?
2. Describe the truth table for a five-input AND gate?
3. How can you use an XOR gate to detect when two bits are different?
4. For the 3-input OR gate, determine the output waveform in proper relation
to the inputs?

A
A
B
B C

X
C

5. Determine the output waveform for the XOR gate and for the XNOR gate,
given the input waveforms, A and B?
A
B
A

B
X

Choose the right answer:


1. An inverter performs an operation known as:
(a) Complementation (b) Assertion
(c) Inversion (d) both a and c
2. The output of an OR gate with inputs A,B, and C is a 1 when:
(a) A=1, B=1, C=1 (b) A=0, B=0, C=1

10
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
(c) A=0, B=0, C=0 (d) All (e) only a and b
3. A pulse is applied to each input of a 2-input NAND gate. One pulse goes
HIGH at t=0 and goes LOW at t=1ms, the other pulse goes HIGH at
t=0.8ms and goes back LOW at t=3ms. the output pulse can be described as
follows:
(a) It goes LOW at t=0 and back HIGH at t=3ms.
(b) It goes LOW at t=0.8ms and back HIGH at t=3ms.
(c) It goes LOW at t=0.8ms and back HIGH at t=1ms.
(d) It goes HIGH at t=0.8ms and back LOW at t=1ms.
4. when the input to an inverter is HIGH, the output is :
(a) HIGH (b) LOW

Example: subtract 3A5(16) from 592(16).


First, covert 3A5 to its 2’s complement form by using either method presented
above. The result is C5B. Then add this to 592.

592
Discarded + C5B
carry 1 1ED

Example: subtract the following hexadecimal numbers:


(a) 84 – 2A (b) C3 – 0B
For branch (a): the 2’s complement of 2A = D6

84
+ D6
Drop carry 1 5A the difference is 5A(16)

For branch (b): the 2’s complement of 0B = F5

C3
+ F5
Drop carry 1 B8 11 the difference is B8(16)
University of Anbar Subject / Digital TechniquesI
College of Engineering First Stage / 2nd Semester
Dept. of Electrical Engineering (2019 – 2020);lecture 3
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Multiplication of Hexadecimal Numbers:
The multiplication of hex numbers is well illustrated in the following
example:

3A right column : A(16 ) × F(16) = 10(10) × 15(10) =150(10) = 96(16)


× F = 6 with carry 9
366 left column : 3(16) × F(16) + 9(16)= 3(10) × 15(10) + 9(10) = 45(10) + 9(10) = 54(10)
=36(16)

12

You might also like