Computer Programming
Lesson 2: Number Systems
Presenter: Joyce C. Malubay
Computer Programming
Lesson 2: Number Systems
Learning Objective
1
Develop knowledge about the
different number systems
2
Convert values into
different number systems
What is the difference between
a number and a digit?
Lesson 2: Number Systems Develop knowledge about the different number systems
Number System
It is a particular way on how to
represent numbers. A number can be
consisted of a digit or a series of
digits.
When we say digit, it is only one symbol that
represent a number. The number 1422 is
consists of 4 digits, 1,4,2, and 2.
Lesson 2: Number Systems Develop knowledge about the different number systems
Number System
Different types:
• Decimal Number System
• Computer Number System
Lesson 2: Number Systems Develop knowledge about the different number systems
Decimal Number System
The number system that we use in
our day-to-day life is the decimal
number system.
Decimal number system has base 10 as it
uses 10 digit from 0-9.
Lesson 2: Number Systems Develop knowledge about the different number systems
Computer Number System
When we type some letters or words, the
computer translates them in numbers as
computers can understand only numbers.
As a computer programmer or an IT
professional, you should understand the
following number systems which are frequently
used in computers.
Binary Octal Hexadecimal
Lesson 2: Number Systems Develop knowledge about the different number systems
Conversions
1 4
Binary to Decimal Binary to Hexadecimal
2 5
Decimal to Binary Hexadecimal to Decimal
3 6
Hexadecimal to Binary Decimal to Hexadecimal
Let’sbegin!
Lesson 2: Number Systems Convert values into different number systems
Binary to Decimal
2 Base/Weight 10
1 x 25 = 32
0- 0-9 4
0 x 2 = 0
3
0 x 2 = 0
Solve: Binary to Decimal Conversion 2
1 x 2 = 4
1
Given: 1001012 = ______ 0 x 2 = 0
Steps: [Link] the given downwards 1 x 20 = 1
[Link] by its weight Ans: 1001012 =
[Link] units from bottom to top
Practice:
1.11012
= 1310
2.01011 2 = 1110
3.111010 2
= 5810
4.1001101 2
= 7710
5.01110101 2 = 117 10
Lesson 2: Number Systems Convert values into different number systems
Decimal to Binary 1/2
= 0
10 Base/Weight 2
20010 = 200/2 =
0- 0-1 100 100/2 =
Solve: Decimal to Binary Conversion 50 50/2
Given: 200 = 110010002 = 25 25/2
10
Steps: [Link] the given decimal and
= 12
divide it by 2
12/2 = 6
[Link] quotient and remainder
[Link] the remainder upwards 6/2 = 3
3/2 = 1
R
0
1
1
Lesson 2: Number Systems Convert values into different number systems
Decimal to Binary
10 Base/Weight 2
0-9 0-1
Solve: Decimal to Binary Conversion
Given: 40010 = 2
Steps: [Link] the given decimal and
divide it by 2
[Link] quotient and remainder
[Link] the remainder upwards
Lesson 2: Number Systems Convert values into different number systems
Decimal to Binary
10 Base/Weight 2
0-9 0-1
Solve: Decimal to Binary Conversion
Given: 25610 = 2
Steps: [Link] the given decimal and
divide it by 2
[Link] quotient and remainder
[Link] the remainder upwards
Lesson 2: Number Systems Convert values into different number systems
Decimal to Binary
10 Base/Weight 2
0-9 0-1
Solve: Decimal to Binary Conversion
Given: 84110 = 2
Steps: [Link] the given decimal and
divide it by 2
[Link] quotient and remainder
[Link] the remainder upwards
Practice:
1.190 10
= 10111110 2
2.68
10 = 1000100
2
3.512 10 = 1000000000 2
4.870 10 = 1101100110 2
5.120 10 = 1111000
2
Lesson 2: Number Systems Convert values into different number systems
Hex to Binary Hex
0
Binary
0000
Dec
0
16 Base/Weight 2 1 0001 1
2 0010 2
0-9ABCDEF 8 4 2 1 0-1
3
4
0011
0100
3
4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
A 1010 10
B 1011 11
C 1100 12
D 1101 13
E 1110 14
F 1111 15
Lesson 2: Number Systems Convert values into different number systems
Hex to Binary
16 Base/Weight 2
143 16
0-9ABCDEF 8 4 2 1 0-1 0001 0100 0011
Solve: Hex to Binary Conversion
Given: 14316 = _______ 2 Ans: 14316 = 1010000112
Steps: [Link] the digits of the
hexadecimal number separately
[Link] the corresponding binary
equivalent
[Link]-out the unnecessary
zeroes at the leftmost digit
Lesson 2: Number Systems Convert values into different number systems
Hex to Binary
16 Base/Weight 2
0-9ABCDEF 8 4 2 1 0-1
Solve: Hex to Binary Conversion
Given: 24616 = 2
Steps: [Link] the digits of the
hexadecimal number separately
[Link] the corresponding binary
equivalent
[Link]-out the unnecessary
zeroes at the leftmost digit
Lesson 2: Number Systems Convert values into different number systems
Hex to Binary
16 Base/Weight 2
0-9ABCDEF 8 4 2 1 0-1
Solve: Hex to Binary Conversion
Given: 76316 = 2
Steps: [Link] the digits of the
hexadecimal number separately
[Link] the corresponding binary
equivalent
[Link]-out the unnecessary
zeroes at the leftmost digit
Practice:
1.190 16
= 110010000 2
2.68
16 = 1101000
2
3.512 16 = 10100010010 2
4.870 16 = 100001110000 2
5.120 16 = 100100000 2
7:30-9:00 M
QUIZ #1: [Link]
1.204 16
6. 772
16
11.119
16
2.88
16 7. 48816 12.127
16
3.9216 8. 39616 13.132
16
4.176 16 9. 55016 14.148
16
5.654 1
10.104 1
15.156 1
10:30-12:00 M
QUIZ #1: [Link]
1.102 16
6. 572
16
11.14816
2.258 16 7. 60416 12.24416
3.7716 8. 72316 13.39616
4.316 16 9. 86616 14.40816
5.489 1
10.900 1
15.549 1
1:00-2:30 M
QUIZ #1: [Link]
1.955 16
6. 501
16
11.913
16
2.832 16 7. 48916 12.888
16
3.5516 8. 30516 13.701
16
4.725 16 9. 27816 14.645
16
5.666 1
10.100 1
15.549 1
4:00-5:30 M
QUIZ #1: [Link]
1.198
16
6. 634
16
11.117
16
2.287
16 7. 75616 12.128
16
3.376 16 8. 84116 13.139
16
4.412
16 9. 95216 14.145
16
5.532 1
10.108 1
15.158 1
10:30-12:00 T
QUIZ #1: [Link]
1.912
16
6. 467
16
11.28716
2.823
16 7. 37816 12.376
16
3.734 16 8. 289 16 13.46516
4.645
16 9. 19016 14.55416
5.556 1
10.198 1
15.643 1
2:30-4:00 T
QUIZ #1: [Link]
1.147
16
6. 693
16
11.234
16
2.258
16 7. 71416 12.456
16
3.369 16 8. 82516 13.567
16
4.471
16 9. 93616 14.678
16
5.582 1
10.123 1
15.789 1
Lesson 2: Number Systems Convert values into different number systems
Binary to Hexadecimal
2 Base/Weight 16
0001 1011 0101 0001
0-1 0-9ABCDEF
1 11 5 1
Solve: Binary to Hexadecimal Conversion
Given: 1101101010001 2 = 1B51
Steps: [Link] the digits of the binary [Link] the
hexadecimal
digit as
digit by 4’s.
[Link] the last group is less
than to the left to make it 4
digits.
number from the last
4 digit, add zeros
a string
Lesson 2: Number Systems Convert values into different number systems
Binary to Hexadecimal
2 Base/Weight 16
0011 1101 1101
0-1 0-9ABCDEF
3 13 13
Solve: Binary to Hexadecimal Conversion
Given: 01111011101 2= 3DD
Steps: [Link] the digits of the binary [Link] the
hexadecimal
digit as
digit by 4’s.
[Link] the last group is less
than to the left to make it 4
digits.
number from the last
4 digit, add zeros
a string
Lesson 2: Number Systems Convert values into different number systems
Binary to Hexadecimal
2 Base/Weight 16
000 1 1110 1110
0-1 0-9ABCDEF
1 14 14
Solve: Binary to Hexadecimal Conversion
Given: 1 1110 1110 2 = 1EE
Steps: [Link] the digits of the binary [Link] the
hexadecimal
digit as
digit by 4’s.
[Link] the last group is less
than to the left to make it 4
digits.
number from the last
4 digit, add zeros
a string
Practice:
1.11012 = D 16
2.01011 2 = 0B 61
3.111010 2
=
4.1001101 2 3A =
16
5.01110101 2 4D
16
Lesson 2: Number Systems Convert values into different number systems
Hexadecimal to Decimal
16 Base/Weight 10
2
7 = 7 x 16 = 1792
0-9ABCDEF 0-9 2 = 2 x 161 = 32
F = 15 x 160 = 15
Solve: Hexadecimal to Decimal Conversion 1839
Given: 72F = 1839
16 10
Steps: [Link] the hexadecimal number downwards, if the hexa
digit is a letter, change it to decimal number
[Link] each number by hexa weight starting with
units at the bottom of the list.
[Link] the product, it will be the final answer
Lesson 2: Number Systems Convert values into different number systems
Hexadecimal to Decimal
16 Base/Weight 10
0-9ABCDEF 0-9
Solve: Hexadecimal to Decimal Conversion
Given: AAC = 2732
16 10
Steps: [Link] the hexadecimal number downwards, if the hexa
digit is a letter, change it to decimal number
[Link] each number by hexa weight starting with
units at the bottom of the list.
[Link] the product, it will be the final answer
Lesson 2: Number Systems Convert values into different number systems
Hexadecimal to Decimal
16 Base/Weight 10
0-9ABCDEF 0-9
Solve: Hexadecimal to Decimal Conversion
Given: ABC = 2748
16 10
Steps: [Link] the hexadecimal number downwards, if the hexa
digit is a letter, change it to decimal number
[Link] each number by hexa weight starting with
units at the bottom of the list.
[Link] the product, it will be the final answer
Practice:
[Link] = 2767
2.94DE = 38110
3.8EEF = 36591
4.4CB = 1227
[Link] = 3006
Lesson 2: Number Systems Convert values into different number systems
Decimal to Hexadecimal
10 Base/Weight 16
R
400/16 = 25 0
0-1 0-9ABCDEF
25/16 = 1 9
Solve: Decimal to Hexadecimal Conversion
1/16 = 0 1
Given: 40010= _
16
Steps: [Link] the decimal number by 16 190
[Link] the quotient (get the whole num) and multiply it by 16
[Link] to the given number to get the remainder
[Link] steps 2 and 3 until the quotient is 0
[Link] the digits from bottom to top.
Lesson 2: Number Systems Convert values into different number systems
Decimal to Hexadecimal
10 Base/Weight 16
R
254/16 = 15 14
0-1 0-9ABCDEF
15/16 = 0 15
Solve: Decimal to Hexadecimal Conversion
FE
Given: 25410= FE
16
Steps: [Link] the hexadecimal number by 16
[Link] the quotient (get the whole num) and multiply it by 16
[Link] to the given number to get the remainder
[Link] steps 2 and 3 until the quotient is 0
[Link] the digits from bottom to top.
Lesson 2: Number Systems Convert values into different number systems
Decimal to Hexadecimal R
10 Base/Weight 16
7562/16 = 472 10
0-1 0-9ABCDEF 472/16 = 29 8
Solve: Decimal to Hexadecimal Conversion 29/16 = 1 13
Given: 7562 1D8A 1/16 = 0 1
1 16
Steps: [Link] the hexadecimal number by 16 1D8A
[Link] the quotient (get the whole num) and multiply it by 16
[Link] to the given number to get the remainder
[Link] steps 2 and 3 until the quotient is 0
[Link] the digits from bottom to top.
Lesson 2: Number Systems Convert values into different number systems
Decimal to Hexadecimal R
10 Base/Weight 16
35631/16 = 2,226 15
0-1 0-9ABCDEF 2,226/16 = 139 2
Solve: Decimal to Hexadecimal Conversion 139/16 = 8 11
Given: 35631 =8B2F 8/16 = 0 8
10 16
Steps: [Link] the hexadecimal number by 16 8B2F
[Link] the quotient (get the whole num) and multiply it by 16
[Link] to the given number to get the remainder
[Link] steps 2 and 3 until the quotient is 0
[Link] the digits from bottom to top.
Lesson 2: Number Systems Convert values into different number systems
Decimal to Hexadecimal R
10 Base/Weight 16
2322/16 = 145 2
0-1 0-9ABCDEF 145/16 = 9 1
Solve: Decimal to Hexadecimal Conversion 9/16 = 0 9
Given: 2322 = 912 912
10 16
Steps: [Link] the hexadecimal number by 16
[Link] the quotient (get the whole num) and multiply it by 16
[Link] to the given number to get the remainder
[Link] steps 2 and 3 until the quotient is 0
[Link] the digits from bottom to top.
Practice:
1.2910 = B5E
2.5782 = 1696
3.8742 = 2226
4.6963 = 1B33
5.8526 = 214E