Professional Documents
Culture Documents
Technology, Karachi
1
Contents of 3rd week
Hexadecimal numbers
Octal numbers
Binary, Octal and Hex conversion
Binary addition
Binary subtraction
1’s Complement
2’s Complement
Signed Binary numbers
Arithmetic operations with signed numbers
2
Hexadecimal Numbers
Decimal Hexadecimal Binary
0 0 0000
Hexadecimal uses sixteen characters to 1 1 0001
represent numbers: the numbers 0 2 2 0010
through 9 and the alphabetic characters 3 3 0011
A through F. 4 4 0100
5 5 0101
6 6 0110
Large binary number can easily 7 7 0111
be converted to hexadecimal by 8 8 1000
grouping bits 4 at a time and writing 9 9 1001
the equivalent hexadecimal character. 10 A 1010
11 B 1011
Express 1001 0110 0000 11102 in 12 C 1100
hexadecimal: 13 D 1101
Group the binary number by 4-bits 14 E 1110
starting from the right. Thus, 960E 15 F 1111
3
Hexadecimal Numbers
Decimal Hexadecimal Binary
0 0 0000
Hexadecimal is a weighted number
1 1 0001
system. The column weights are 2 2 0010
powers of 16, which increase from 3 3 0011
right to left. 4 4 0100
5 5 0101
6 6 0110
{
163 162 161 160.
Column weights 4096 256 16 1 .
7
8
7
8
0111
1000
9 9 1001
Express 1A2F16 in decimal. 10 A 1010
11 B 1011
Start by writing the column weights:
12 C 1100
4096 256 16 1
13 D 1101
1 A 2 F16
14 E 1110
1(4096) + 10(256) +2(16) +15(1) = 670310 15 F 1111
4
Octal Numbers
Decimal Octal Binary
0 0 0000
Octal uses eight characters the numbers
1 1 0001
0 through 7 to represent numbers. 2 2 0010
There is no 8 or 9 character in octal. 3 3 0011
4 4 0100
5 5 0101
Binary number can easily be
6 6 0110
converted to octal by grouping bits 3 at 7 7 0111
a time and writing the equivalent octal 8 10 1000
character for each group. 9 11 1001
10 12 1010
Express 1 001 011 000 001 1102 in
11 13 1011
octal: 12 14 1100
Group the binary number by 3-bits 13 15 1101
starting from the right. Thus, 1130168 14 16 1110
15 17 1111
5
Octal Numbers
Decimal Octal Binary
6
Binary ↔ Octal ↔ Hex Shortcut
Because binary, octal, and hex number systems are all powers of two
(which is the reason we use them) there is a relationship that we can
exploit to make conversion easier.
1 0 1 1 0 1 0 2 = 132 8 = 5A H
To convert directly between binary and octal, group the binary bits into
sets of 3 (because 23 = 8). You may need to pad with leading zeros.
0 0 1 0 1 1 0 1 0 2= 1 3 28
5 A 0101 1 010
Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
7
Example: Binary ↔ Octal ↔ Hex
Example:
Using the shortcut technique, convert the hexadecimal number A616
into its binary and octal equivalent. Use your calculator to check your
answers.
Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
8
Example: Binary ↔ Octal ↔ Hex
Example:
Using the shortcut technique, convert the hexadecimal number A616
into its binary & octal equivalent. Use your calculator to check your
answers.
Solution:
First convert the hexadecimal number into binary by expanding the
hexadecimal digits into binary groups of (4).
A 6 16
A616 = 101001102
1010 0110
Convert the binary number into octal by grouping the binary bits into
groups of (3).
010100110
101001102 = 2468
2 4 6
Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
9
Binary Addition
10
Binary Addition
11
Binary Subtraction
12
1’s Complement
0 0 1 1 0 1 0 1
13
2’s Complement
0 0 1 1 0 1 0 1
Input bits
Carry
Adder
in (add 1)
Output bits (sum)
0 0 1 1 0 1 1 0
14
Signed Binary Numbers
15
Signed Binary Numbers
16
Arithmetic Operations with Signed Numbers
17
Arithmetic Operations with Signed Numbers
18
Arithmetic Operations with Signed Numbers
19
Thanks
Q&A
20