Number Systems
Number Systems
1
Different types of numbering systems
• Decimal
- All existing numbers in the decimal system include.
- 0123456789
• Binary
- All existing numbers in the binary system include
-01
• Hexadecimal
- All existing numbers in the hexadecimal system include
- 0123456789ABCDEF
• Octal
- All existing numbers in the octal system include
- 01234567
2
Binary numbering system
• A binary number can only be one of two values (i.e., 1
or 0)
This switch is on
3
Binary numbering system
• How many outcomes are possible with two switches?
off off off on
on off on on
4
Binary numbering system
• Instead of switches, let's use binary numbers 1 and 0
4 Possibilities
0 1
1 0
1 1
5
Binary numbering system
• How many outcomes are possible with three switches?
8 Possibilities
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
6
Binary Numbering System
• Did you notice that...
2 n
7
Binary Numbering System
• Given n binary numbers, 2n determines the number of
possible outcomes.
n (# of binary numbers) 2n (# of possible outcomes)
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024
8
Converting Binary to Decimal Numbers
• Now that you know what binary numbers look like let’s
see how to convert them into decimal numbers.
Decimal value 32 16 8 4 2 1
2n 25 24 23 22 21 20
position 6th 5th 4th 3rd 2nd 1st
9
Converting Binary to Decimal Numbers
• To determine the value of a binary number you must
do the following.
Binary number * 2n 1 * 23 0 * 22 0 * 21 1 * 20
Binary number 1 0 0 1
10
Converting Binary to Decimal Numbers
• Let’s try it again. Determine the decimal value of binary
1111.
Decimal value 8 4 2 1 8 + 4 + 2 + 1 = 15
Binary number * 2n 1 * 23 1 * 22 1 * 21 1 * 20
Binary number 1 1 1 1
11
Converting Binary to Decimal Numbers
• Let’s try it again. Determine the decimal value of binary
1010.
Decimal value 8 0 2 0 8 + 0 + 2 + 0 = 10
Binary number * 2n 1 * 23 0 * 22 1 * 21 0 * 20
Binary number 1 0 1 0
12
Converting Decimal to Binary Numbers
• How do you convert decimal numbers into binary
numbers?
Binary number 1 0 0 0 0 1 1 1
13
Converting Decimal to Binary Numbers
• Convert decimal 175 into a binary number.
Binary number 1 0 1 0 1 1 1 1
14
Hexadecimal Numbers
• Another popular numbering system that is used in the realm of
computers and software is call hexadecimal.
0000 0 0 1000 8 8
0001 1 1 1001 9 9
0010 2 2 1010 A 10
0011 3 3 1011 B 11
0100 4 4 1100 C 12
0101 5 5 1101 D 13
0110 6 6 1110 E 14
0111 7 7 1111 F 15
16
Converting Hexadecimal into Binary
• Consider the following example of how to convert hexadecimal number
9A35H into a binary number.
Hexadecimal 9 A 3 5
• Simply group the binary number into groups of four digits (from right to
left) and convert each group into a hexadecimal number.
• Use leading zeroes for groups that don’t have four digits. For example,
- 1111010110100001 <<< Original binary number
- 1111 0101 1010 0001 <<< Grouped binary number
-F 5 A 1 <<< Converted into hexadecimal
18
Hexadecimal to Decimal Conversion
19
Hexadecimal to Decimal Conversion
• Step 1: Convert F7H to binary. Write four binary
number positions for each hex number.
F 7
8 4 2 1 8 4 2 1
20
Hexadecimal to Decimal Conversion
• Step 2: Fill in the binary numerical values for each
hexadecimal number.
F 7
8 4 2 1 8 4 2 1
1 1 1 1 0 1 1 1
21
Hexadecimal to Decimal Conversion
• Step 3: Treat all the sets of binary numbers as one
connected binary number.
F 7
128 64 32 16 8 4 2 1
1 1 1 1 0 1 1 1
22
Hexadecimal to Decimal Conversion
128 64 32 16 8 4 2 1
1 1 1 1 0 1 1 1
247
23
Decimal to Hexadecimal Conversion
24
Decimal to Hexadecimal Conversion
• Step 1: Convert 135 to binary. Write the necessary
binary positions to accommodate the entire number.
128 64 32 16 8 4 2 1
25
Decimal to Hexadecimal Conversion
• Step 2: Activate those numbers that add up to 135.
128 64 32 16 8 4 2 1
1 0 0 0 0 1 1 1
26
Decimal to Hexadecimal Conversion
• Step 3: Split the binary number into groups of four
starting from the right hand side.
128 64 32 16 8 4 2 1
1 0 0 0 0 1 1 1
128 64 32 16 8 4 2 1
1 0 0 0 0 1 1 1
• Note: Add prefix zeros if the last group does not have
enough binary digits to create a group of four.
27
Decimal to Hexadecimal Conversion
• Step 4: Change the numerical position values for each
group to 8 4 2 1.
8 4 2 1 8 4 2 1
1 0 0 0 0 1 1 1
28
Decimal to Hexadecimal Conversion
• Step 5: Convert each group to a hexadecimal number
8 4 2 1 8 4 2 1
1 0 0 0 0 1 1 1
8 7
29
Adding Binary
Numbers
30
Adding Binary Numbers
• One thing to remember when adding binary numbers
together is that the result is either a 0 or a 1.
+1
10
31
Adding Binary Numbers
• Example: Add binary 110 with 111.
110
111
1
32
Adding Binary Numbers
• Step 3: Add the next two numbers.
Carry the 1
1
110
111
01
33
Adding Binary Numbers
• Step 4: Add the next two numbers.
Carry the 1
1
110
111
1101
34
Adding Binary Numbers
• As a verification we can convert the binary numbers to
decimal, add them, and then determine if the sum is
correct.
Binary Decimal
110 6
111 7
1101 13
35