Lecture # 2B - Numbers Systems, Operations and Codes
Lecture # 2B - Numbers Systems, Operations and Codes
INFORMATION TECHNOLOGY
How do you count in hexadecimal once you get to F? Simply start over with
another column and continue as follows:
…,E,F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23,24,25,26,27,
28,29,2A,2B,2C,2D,2E,2F,30,31,…
With two hexadecimal digits, you can count up to FF16 Which is decimal 256,
10116 is decimal 257, and so forth. The maximum 3-digit hexadecimal number is
FFF16 decimal is 4095. the maximum number FFFF16 decimal IS 65535.
Hexadecimal Numbers
Binary to Hexadecimal Conversion
Converting a binary number to hexadecimal is a straightforward
procedure. Simply break the binary number into 4-bit groups,
starting from right-most bit and replace 4-bit group with the
equivalent hexadecimal symbol.
a) 1100101001010111
1100 1010 0101 0111
C A 5 7 = CA5716
b) 00111111000101101001
0011 1111 0001 0110 1001
3 F `1 6 9 = 3F16916
Hexadecimal Numbers
Hexadecimal Conversion to Binary
To convert from hexadecimal number to a binary number, reverse
the process and replace each hexadecimal with appropriate four
bits.
a) 10A416 b) CF8E16
Solution
1 0 A 4 C F 8 E
1 0000 1010 0100 1100 1111 1000 1110
c) 974216
9 7 4 2 problem convert hexadecimal
1001 0111 0100 0010 number 6BD3 to binary
Hexadecimal Numbers
Hexadecimal Conversion to Decimal Conversion
at first convert the hexadecimal number to binary and then convert
from binary to decimal.
a) 1C16
Solution
Step 1 hexadecimal to binary
1 C
0001 1100
Step 2 binary to decimal
00011100 = 24 + 23 + 22 = 16 + 8 + 4 = 2810
Hexadecimal Numbers
Hexadecimal Conversion to Decimal Conversion
b) A85 16
Solution
Sep 1 convert hexadecimal to binary
A 8 5
10101000 0101
Step 2 convert binary to decimal
= 211 + 29 + 27 + 22 + 20
= 2048 + 512 + 128 + 4 + 1
= 269310
Hexadecimal Numbers
Hexadecimal Conversion to Decimal Conversion
Another way to convert hexadecimal number to decimal equivalent
is to multiply the decimal value of each hexadecimal digit by its
weight and then sum of these product.
a) E516
Solution
= (E x 16) + (5 x 1)
E = 14
= (14 x 16) + (5x 1)
= 224 + 5
= 22910
Hexadecimal Numbers
Hexadecimal Conversion to Decimal Conversion
b) B2F816
Solution
= (B x 16) + (2 x 256) + (F x 16) + (8 x 1)
B = 11, F = 16
= (11 x 16) + (2 x 256) + (15 x 16) + (8 x 1)
= 45056 + 512 + 240 + 8
= 4581610
PROBLEM
Convert 60A16 to decimal
Hexadecimal Numbers
Decimal Conversion to Hexadecimal Conversion
Division of decimal number by 16 will produce the equivalent
hexadecimal number, formed by the remainder of the divisions.
Convert the decimal number 650 to hexadecimal by division 16.
Solution
650/16 = 40.625 x 16 = 10 = A
40/16 = 2.5 = 0.5 x 16 = 8
2/16 = 0.125 x 16 = 2
Quotient = 0
Hexadecimal number = 28A16
Problem: Convert 2591 to hexadecimal.
Hexadecimal Numbers
Hexadecimal addition
Addition can be done directly with hexadecimal numbers by
remembering that the hexadecimal digit 0 to 9 are equivalent to
decimal 0 to 9 and that hexadecimal digits A through F are
equivalent to decimal 10 to 15. e.g. 516 = 510 C16 = 1210
a) 2316 + 1616
2316 right column: 316 + 616 = 310 + 610 = 910 = 916
+ 1616 left column: 216 + 116 = 210 + 110 = 310 = 316
3916
Hexadecimal Numbers
Hexadecimal addition
b) 5816 + 2216
5816 right column: 816 + 216 = 810 + 210 = 1010 = A16
+ 2216 left column: 516 + 216 = 510 + 210 = 710 = 716
7A16
c) 2B16 + 8416
2B16 right column: B16 + 416 = 1110 + 410 = 1510 = F16
+ 8416 left column: 816 + 216 = 810 + 210 = 1010 = A16
AF16
Hexadecimal Numbers
Hexadecimal addition
d) DF16 + AC16
DF16 right column: F16 + C16 = 1510 + 1210 = 2710
2710 – 1610 = 1110 = B16 with 1 carry
+ AC16 left column: D16 + A16 + 1 = 1310 + 1010 + 1= 2410 = 716
18B16 2410 – 1610 = 810 = 816 with 1 carry
Problem
Add 4C16 + 3A16
Hexadecimal Numbers
Hexadecimal Subtraction
We know that the 2’s complement allow you to subtract by adding
binary numbers.
A hexadecimal number can be used to represent a binary number,
it can also be used to represent the 2’s complement of a binary
number.
Method 1
Convert the hexadecimal number to binary. Take the 2’s
complement of the binary number. Convert the result into
hexadecimal number.
2’s complement 2’s complement
hexadecimal binary in binary in hexadecimal
number number
Hexadecimal Numbers
Hexadecimal Subtraction
Example
11010110
2A 00101010 D6
Method 2
Subtract the hexadecimal number from the maximum hexadecimal number
and add 1
Subtraction 1’s complement
2’s complement
from maximum in hexadecimal
hexadecimal in hexadecimal
plus 1
Hexadecimal Numbers
Hexadecimal Subtraction
Example
D5 + 1
2A FF – 2A D6
SUBTRACT
8416 + 2A16
Solution
Step 1
2A16 = 00101010
2’s complement 2A16 = 11010110
Convert into hexadecimal = D616
Hexadecimal Numbers
Hexadecimal Subtraction
Example
SUBTRACT
C316 + 0B16
Solution
Step 1
0B16 = 00001011
2’s complement 10B16 = 11110101
Convert into hexadecimal = F516
Q/A