You are on page 1of 25

Number Bases

Base Conversion
Number systems

 Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 Binary – 0, 1
 Octal – 0, 1, 2, 3, 4, 5, 6, 7
 Base Five
 Hexadecimal system – 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, A, B, C, D, E, F

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 2
Why different number systems?

 Binary number result in quite a long


string of 0s and 1s
 Easier for the computer to interpret input
from the user

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 3
Base Conversion

 In daily life, we use decimal (base 10)


number system
 Computer can only read in 0 and 1
 Number system being used inside a
computer is binary (base 2)
 Octal (base 8) and hexadecimal (base 16)
are used in programming for convenience

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 4
Base Conversion

 Conversion
 Binary number,
 Octal number,

 Hexadecimal number, and

 Decimal number.

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 5
Base Conversion
Decimal Binary Octal Base Five Hexadecimal
0 0000 0 0 0
1 0001 1 1 1
2 0010 2 2 2
3 0011 3 3 3
4 0100 4 4 4
5 0101 5 10 5
6 0110 6 11 6
7 0111 7 12 7
8 1000 10 13 8
9 1001 11 14 9
10 1010 12 20 A
11 1011 13 21 B
12 1100 14 22 C
13 1101 15 23 D
14 1110 16 24 E
15 1111 17 30 F

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 6
Base Conversion
For example:
62 = 111110 = 76 = 222
Decimal binary octal base five

1 For Decimal:
62 = 6x101 + 2x100
2 For Binary:
111110 = 1x25 + 1x24 + 1x23 + 1x22 + 1x21 + 0x20
3 For Octal:
76 = 7x81+ 6x80
4 For Base Five:
189 = 2x52 + 2x51 + 2x50
HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 7
Binary and decimal system

 Binary to decimal
 X . 2 7 + X . 2 6 + X . 2 5 + X . 2 4 + X . 2 3 + X . 2 2+ X . 2 1 + X .
20
 Decimal to binary
 Keep dividing the number by two and keep
track of the remainders.
 Arrange the remainders (0 or 1) from the
least significant (right) to most significant (left)
digits
 Example – see next slide
HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 8
Base 10 to Base 2 Conversion

 How to convert the decimal number to


other number system
 e.g. convert 1810 in binary form
2 |18 ----0
2 |09 ----1
2 |04 ----0
2 |02 ----0
0 ----1
 1810 = 100102
HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 9
Conversion Between Base 8 and Base 2

 Binary to Octal (8 = 23)


 Every 3 binary digit equivalent to one octal digit
e.g. 10010 = 010 010
2 2
Thus, 100102 = 228
 Octal to binary
 Every one octal digit equivalent to 3 binary digit
268= 101102
102 1102

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 10
Base 10 and Base 8 Conversion
 How to convert the decimal number to
octal system
 e.g. convert 1910 in octal form
8 |19 ----3
8 | 2 ----2
0
1810 = 238
 Convert 458 to decimal number
 458= 3710
4x81+ 5x80
HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 11
Base 10 and Base 5 Conversion
 How to convert the decimal number to
octal system
 e.g. convert 1910 to base 5
5 |19 ----4
5 | 3 ----3
0
1810 = 345
 Convert 435 to decimal number
435= 2310
4x51+ 3x50
HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 12
Base 2 and 5 Conversion

 convert 100102 in base 5


 base 2 base 10 base 5
 100102 = 1810 = 335
||||
16 8 4 2 1

5 |18 ----3
5 | 3 ----3
0
100102 = 335

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 13
Number Bases

Addition & Subtraction


Decimal Addition
What is going on?
111
3758 111 (carry)
3758
+ 4657
+4657
8415 -
14 11 15
10 10 10 (subtract the base)

8415

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 15
Binary Addition

Rules.
 0+0=0
 0+1=1

 1+0=1

 1 + 1 = 2 = 102 = 0 with 1 to carry

 1 + 1 + 1 = 3 = 112 = 1 with 1 to carry

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 16
Binary Addition

Verification
1111 5510
110111 + 2810
+ 011100 8310

232 2
64 32 16 8 4 2 1
- 222 2 1 0 1 0 011
1010011 = 64 + 16 + 2 +1
= 8310

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 17
Binary Addition

e.g.
100111+ 10110 =
Verification
100111
+ 010110

___________

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 18
Octal Addition

11
6437 8

+ 251 0 8

99
- 88 (subtract Base (8))
1114 7 8

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 19
Octal Addition

ex

3536 8

+ 2 4 5 78

- 3 6 78 (subtract Base (8))

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 20
Decimal Subtraction
How it was done?
( add the base 10 when borrowing)
7 13 10 10 10
8 4 1 15 7 3 0 10
- 4 6 5 7 8 4 1 5
13 10 15
3 7 5 8 -4 6 5 7
3 7 5 8

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 21
Binary Subtraction
Verification
8310
- 2810
110 1 5510
0 10 0 1010

1 0 1 0 0 1 12 64 32 16 8 4 2 1
- 0 1 1 1 0 02 1 1 0 1 1 1
= 32 + 16 + + 4 + 2 +1
1 1 0 1 1 12
= 5510

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 22
Binary Subtraction

exercise
100111- 10110=
Verification
100101
- 010110

___________

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 23
Octal Subtraction

8
009
1 1 1 4 78
- 64378
2 51 0 8

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 24
Octal Subtraction
ex

3 5 3 68

- 2 4 5 78

HML\D:\D_My Document\My
Documents\maths\SPM\form5\lessons 25

You might also like