Number System
1
Lecture 1 Coverage:
❖ Number Base System
o Decimal Number System
o Binary Number System
o Octal Number System
o Hexadecimal Number System
2
Decimal Number System:
• Our everyday number system.
• The Base-10 number system
• It has 10 digits to show all numbers
0,1,2,3,4,5,6,7,8,9
• Can be expressed as the power of base 10.
• Example : 12510 or simply, 125
15010 or simply, 150
3
Binary Number System:
• Computers use binary numbers and therefore use
binary digits in place of decimal digits.
• The word bit is a shortening of the words "Binary
digIT."
• bits have only two possible values: 0 and 1.
• Example: 10012, 11010012,112 etc.
4
Octal Number System:
• The word “Octal" means "based on 8“
• There are 8 octal digits
0, 1, 2, 3, 4, 5, 6 & 7
• Example: 2078 , 134 8 , 270 8 etc.
5
Hexadecimal Number System:
• The word "Hexadecimal" means "based on 16“
• There are 16 Hexadecimal digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D,E and F
• Example: 2E6, D13E, ABC, etc.
6
In Summary..
System Base Digits Example
Decimal 10 0, 1, … 9 12 , 2300
Binary 2 0, 1 1002, 11011112
Octal 8 0, 1, … 7 1048, 10348, 728
Hexa- 0, 1, … 9,
16 2AE, 34816
decimal A, B, … F
7
Any Questions?
8
Bases Conversion:
• The conversion possibilities:
Decimal Octal
Binary Hexadecimal
9
Binary to Decimal (1):
Decimal Octal
Binary Hexadecimal
10
Binary to Decimal (2):
• Technique
– Multiply each bit by 2n, where n = 0,1,2,3,……,n
– The weight is the position of the bit, starting from 0
on the right
– Add the results
11
Binary to Decimal (3) – Example:
1010112 = ?10
Bit
“0”
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
12
Octal to Decimal (1):
Decimal Octal
Binary Hexadecimal
13
Octal to Decimal (2):
• Technique
– Multiply each bit by 8n, where n = 0,1,2,3,……..,n
– The weight is the position of the bit, starting from 0
on the right
– Add the results
14
Octal to Decimal (3) – Example:
7248 = ?10
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
15
Hexadecimal to Decimal (1):
Decimal Octal
Binary Hexadecimal
16
Hexadecimal to Decimal (2)
• Technique
– Multiply each bit by 16n, where n= 0,1,2,3,…….n
– The weight is the position of the bit, starting from 0
on the right
– Add the results
17
Hexadecimal to Decimal (3)-Example
ABC16 = ?10
ABC16 => C x 160 = 12 x 1 = 12
B x 161 = 11 x 16 = 176
A x 162 = 10 x 256 = 2560
274810
18
Decimal to Binary (1):
Decimal Octal
Binary Hexadecimal
19
Decimal to Binary (2):
• Technique
– Divide by two, keep track of the remainder
– First remainder is bit 0 (LSB, least-significant bit)
– Second remainder is bit 1
20
Decimal
125 = ?
to Binary (3) – Example:
10 2
2 125
2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1
12510 = 011111012
21
Decimal to Octal (1):
Decimal Octal
Binary Hexadecimal
22
Decimal to Octal (2)
• Technique
– Divide by 8
– Keep track of the remainder
23
Decimal to Octal (3) – Example:
123410 = ?8
8 1234
8 154 2
8 19 2
8 2 3
0 2
123410 = 23228
24
Decimal to Hexadecimal (1):
Decimal Octal
Binary Hexadecimal
25
Decimal to Hexadecimal (2)
• Technique
– Divide by 16
– Keep track of the remainder
26
Decimal to Hexadecimal (3) – Example:
123410 = ?16
16 1234
16 77 2
16 4 13 = D
16 0 4
123410 = 4D216
27
Octal to Binary (1):
Decimal Octal
Binary Hexadecimal
28
Octal to Binary (2):
• Technique
– Convert each octal digit to a 3-bit equivalent binary
representation
29
Octal to Binary (3) – Example:
7058= ?2
7 0 5
111 000 101
7058= 1110001012
30
Hexadecimal to Binary (1)
Decimal Octal
Binary Hexadecimal
31
Hexadecimal to Binary (2)
• Technique
– Convert each hexadecimal digit to a 4-bit equivalent
binary representation
32
Hexadecimal to Binary (3) – Example:
10AF16= ?2
1 0 A F
0001 0000 1010 1111
10AF16 = 00010000101011112
33
Binary to Octal (1):
Decimal Octal
Binary Hexadecimal
34
Binary to Octal (2):
• Technique
– Group bits in threes, starting on right
– Convert to octal digits
35
Binary to Octal (3) – Example:
10110101112 = ?8
1 011 010 111
1 3 2 7
10110101112 = 13278
36
Binary to Hexadecimal (1):
Decima
Octal
l
Binary Hexadecimal
37
Binary to Hexadecimal (2):
• Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits
38
Binary to Hexadecimal (3) – Example:
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
39
Octal to Hexadecimal (1):
Decimal Octal
Binary Hexadecimal
40
Octal to Hexadecimal (2):
• Technique
– Use binary as an intermediary
– Group 4 bits starting from right
41
Octal to Hexadecimal (3) – Example:
10768 = ?16
1 0 7 6
001 000 111 110
2 3 E
10768 = 23E16
42
Hexadecimal to Octal (1):
Decimal Octal
Binary Hexadecimal
43
Hexadecimal to Octal (2):
• Technique
– Use binary as an intermediary
– Group 3 bits starting from right
44
Hexadecimal to Octal (3) – Example:
1F0C16 = ?8
1 F 0 C
0001 1111 0000 1100
1 7 4 1 4
1F0C16 = 174148
45
Any Questions?
46
Exercise – Convert and fill the table.
Decimal Binary Octal Hexa-decimal
35
1111101
605
10A
Don’t use a calculator!
47
Exercise – Answers:
Decimal Binary Octal Hexa-decimal
35 100011 43 23
125 1111101 175 7D
389 110000101 605 185
266 000100001010 412 10A
48
Fractional numbers
Decimal to binary
3.14579 = 3 + 0.14579 .14579
x 2
3.14579 0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
11.001001.. 1.33056
etc.
49
Exercise – Convert and fill the table
Decimal Binary Octal Hexa-decimal
30.8
110.1100
5.45
F.34
Don’t use a calculator!
50
Any Questions?
51
Summary: Week 1 Lecture:
❖ Number Base System
o Decimal Number System
o Binary Number System
o Octal Number System
o Hexadecimal Number System
❖ Number Base Conversion
❖ 1’s and 2’s Complement
52
Thank you