Binary, decimal, hexadecimal number representation, converting between
Applications and relative advantages
Addition and subtraction in binary, range of n-bit numbers
2. Topics: Number systems, and binary arithmetic
• Binary, decimal, hexadecimal number representation, converting
between
• Applications and relative advantages
• Addition and subtraction in binary, range of n-bit numbers
• Sample activities:
• Paired activity: Exercises converting between the different number
systems
• Group activity: Discuss relative advantages and disadvantages
between applications
• Individual activity: Calculations using different number bases
14/5/2019 Digital Principles_HND L4 2
3. Number Systems
• Common types of number systems used in Digital and
Computer Technology:
• Decimal (base 10)
• Binary (base 2)
• Octal (base 8 but obsolete)
• Hexadecimal (base 16)
Digital Principles_HND L414/5/2019 4
4. Positional values ( weights)
104 103 102 101 100
Decimal Numbering System
7 3 461
• Has ten symbols: ‘0’ through ‘9’
• Each position in the symbol sequence is
weighted by a factor of ten more than the
one to the right
• E.g.:
7316410 = 7 × 104 + 3 × 103 + 1 × 102 + 6 × 101 + 4 × 100
Digital Principles_HND L414/5/2019 5
5. Positional values ( weights)
24 23 22 21 20
• Has two symbols: ‘0’ and ‘1’
• Each position weighted by a factor of two
more than the one to the right.
• E.g.:
101012 = 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 2110
Binary Numbering System
1 0 101
Digital Principles_HND L414/5/2019 6
6. • The least significant bit of the binary
representation of Even quantities is ‘0’
and Odd quantities is ‘1’.
• Doubling a decimal value will have the
equivalent effect of shifting the binary
value to the left by one position
E.g.:
210 = 00102, 410 = 01002 , 810 = 10002
Counting in Binary System
Decimal System Binary System
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111Digital Principles_HND L414/5/2019 7
7. Range of Binary Representation
• What is the largest number that can be represented
using N bits?
• The more bits, the bigger the number
• E.g. If no. of bits, N = 8 , when all the bits are 1s , then the
largest number is 255
• Alternatively , it can be calculated as shown below
2N – 1 = 28 – 1
= 25510
= 111111112
Digital Principles_HND L414/5/2019 8
8. 1)Justify whether the binary number 110012 is equal to 2510 (decimal
form).
2)What is the largest number that can be represented using 8 bits?
Show your steps clearly.
3) Convert the binary number 1011 0101 1100 01102 to its
hexadecimal form (base 16)
14/5/2019 Digital Principles_HND L4 9
9. Justify whether the binary number 110012
is equal to 2510 (decimal form).
• Yes.
• 1x24 + 1x23 + 0x22 + 0x21 + 1x20
• = 16 + 8 + 0 + 0 + 1
• = 2510
14/5/2019 Digital Principles_HND L4 10
10. What is the largest number that can be
represented using 6 bits? Show your steps clearly.
• 255
• 26 – 1 = 25510
• = 111111112
14/5/2019 Digital Principles_HND L4 11
11. Convert the binary number 1011 0101 1100 01102 to its hexadecimal
form (base 16).
• 1011 = 11 (B)
• 0101 = 5
• 1100 = 12 (C)
• 0110 = 6
• 1011 0101 1101 01002 = B5C616
14/5/2019 Digital Principles_HND L4 12
12. Positional values ( weights)
163 162 161 160
F DEE
Hexadecimal Numbering System
• Has 16 symbols: ‘0’ through ‘F’
• Each position weighted by a factor of
sixteen more than the symbol to the right.
• E.g.:
FEED16 = 15×163 + 14×162 + 14×161 + 13×160 = 6526110
Digital Principles_HND L414/5/2019 13
13. Decimal-to-Binary Conversion
• Various methods can be used, 2 of which are:
• Sum-of-Weight Method
• Repeated Division-by-2 Method
Digital Principles_HND L414/5/2019 15
16. 14/5/2019 Digital Principles_HND L4 18
Convert decimal 35 into Binary number.
Divide 35 by 2: 17 remainder 1
Divide 17 by 2: 8 remainder 1
Divide 8 by 2: 4 remainder 0
Divide 4 by 2: 2 remainder 0
Divide 2 by 2: 1 remainder 0
Divide 1 by 2: 0 remainder 1
►Put together the remainders from bottom to top:
► Decimal 3510 ≡ Binary 1000112
17. 14/5/2019 Digital Principles_HND L4 19
The same method can be used to convert to
hexadecimal (16-symbol) numbers too.
Let us consider again 3510.
Divide 35 by 16:2 remainder 3
Divide 2 by 16: 0 remainder 2
►Put together the remainders from bottom to
top:
► 3510 ≡ 2316
18. Hexadecimal-to-Binary Conversion
• Convert each digit of the Hexadecimal System number
to its 4-bit Binary System representation
• E.g.: Hexadecimal System Binary System
20016 0010 0000 00002
3E16 0011 11102
1FA16 0001 1111 10102
123D16 0001 0010 0011 11012
Digital Principles_HND L414/5/2019 20
19. 14/5/2019 Digital Principles_HND L4 21
System: A B C
Number of symbols used: 10 2 16
Symbol of smallest value: 0 0 0
Symbol of largest value 9 1 F
20. 14/5/2019 Digital Principles_HND L4 22
Decimal System Binary System Hexadecimal System
0 0 0
1 1 1
2 ? 2
3 11 ?
4 100 4
5 ? ?
6 ? ?
7 111 7
8 ? ?
9 1001 ?
10 1010 A
11 ? ?
12 1100 C
13 ? ?
14 ? ?
15 1111 F
16 ? ?
21. 14/5/2019 Digital Principles_HND L4 23
Decimal System Binary System Hexadecimal System
252 1111 1100 FC
253 1111 1101 FD
254 1111 1110 FE
255 ? ?
256 1 0000 0000 100
257 ? ?
258 ? 102
.
.
.
.
.
.
.
.
.
1023 11 1111 1111 3FF
1024 ? 400
1025 ? ?
22. 14/5/2019 Digital Principles_HND L4 25
Now, convert the binary number systems to decimal
system.
(i) 10112
= (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20)
= 8 + 2 + 1
= 1110
(ii) 101012
= (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
=16 + 0 + 4 + 0 + 1
=2110
23. 14/5/2019 Digital Principles_HND L4 27
Convert the following binary numbers to decimal:
a) 0110
b) 1010
c) 1111 0101
d) 1010 1011
Convert the following decimal numbers to its binary equivalent
representation.
a) 7
b) 14
c) 28
24. 14/5/2019 Digital Principles_HND L4 28
Convert the following hexadecimal numbers into its
decimal AND binary representation.
a) 3C
b) 50F
c) BEEF
25. 14/5/2019 Digital Principles_HND L4 29
Converting Binary (base 2) to Decimal system (base 10)
10112 = (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20)
= 8 + 0 + 2 + 1
= 1110
Converting Hexadecimals (base 16) to Decimal system (base 10)
A316 = (A16 x 161) + (316 x 160)
= (10 x 161) + (3 x 160)
= 160 + 3
= 16310
26. How Are They Different?
• Decimal vs Hexadecimal vs Octal vs Binary
Decimal Hexadecimal Octal Binary
Base 10 16 8 2
Symbols 0 – 9 0 – 9 , A – F 0 – 7 0 – 1
Number of
symbols
10 16 8 2
Highest
Symbol Value
9 F 7 1
Digital Principles_HND L414/5/2019 30