Lesson4 Number Systems
Lesson4 Number Systems
Types Of Numbers
Natural Numbers
The number 0 and any number obtained by
repeatedly adding a count of 1 to 0
Negative Numbers
A value less than 0
Integer
A natural number, the negative of a natural number,
and 0.
So an integer number system is a system for
‘counting’ things in a simple systematic way
Exponent Review
An exponent (power) tells you how many times
to multiply the base by itself:
2 =2
1
2 = 2 x 2 =4
2
2 =2x2x2=8
3
1 / x2 = x -2
Numbering Systems
Position weights 2 4 2 3 2 2 21 2 0
digits 1 0 1 1
Binary Numbering System
How is a positive integer represented in binary?
Let’s analyze the binary number 110:
110 = (1 x 22) + (1 x 21) + (0 x 20)
= (1 x 4) + (1 x 2) + (0 x 1)
Position weights 22 21 20
Number digits 1 1 0
0 x20 = 0 +
1 x21 = 2 +
1 x 22 = 4
6
positional powers of 2: 2 4 2 3 2 2 21 2 0
decimal positional value: 16 8 4 2 1
binary number: 1 0 1 1 1
16 + 4 + 2 + 1 = 2310
Binary to Decimal Conversion
Example #3: 1100102
positional powers of 2: 2 5 24 23 22 21 20
decimal positional value: 32 16 8 4 2 1
binary number: 1 1 0 0 1 0
32 + 16 + 2 =
5010
Decimal to Binary Conversion
The Division Method:
1) Start with your number (call it N) in base 10
2) Divide N by 2 and record the remainder
3) If (quotient = 0) then stop
else make the quotient your new N, and go back to step 2
The remainders comprise your answer, starting with the last
remainder as your first (leftmost) digit.
2 ) 56 Rem:
2 ) 28 0
2 ) 14 0
2 ) 7 0
2 ) 3 1
2 ) 1 1
0 1
Decimal to Binary Conversion
The Subtraction Method:
Subtract out largest power of 2 possible
(without going below zero), repeating until you
reach 0.
Place a 1 in each position where you
21 26 2 5 24 2 3 2 2 21 2 0
- 16 64 32 16 8 4 2
1 5 0 1 0 1
1- 4
1
- 1 Answer: 2110 = 101012
Decimal to Binary Conversion
Example 2: 5610
56 26 | 25 24 23 22 21 20
- 32 64| 32 16 8 4 2 1
24 |1 1 1 0 0 0
- 16
8
- 8 Answer: 5610 = 1110002
0
Octal Numbering System
Base: 8
Digits: 0, 1, 2, 3, 4, 5, 6, 7
= (3 x 82 ) + (5 x 81) + (7 x 80)
To convert to base 10, beginning with the
rightmost digit, multiply each nth digit by 8(n-1),
and add all of the results together.
Octal to Decimal Conversion
Example 1: 3578
positional powers of 8: 82 81 80
decimal positional value: 64 8 1
Octal number: 3 5 7
(3 x 64) + (5 x 8) + (7 x 1)
= 192 + 40 + 7 = 23910
Octal to Decimal Conversion
Example 2: 12468
positional powers of 8: 83 82 8 1 80
decimal positional value: 512 64 8 1
Octal number: 1 2 4 6
(1 x 512) + (2 x 64) + (4 x 8) + (6 x 1)
8 ) 214 Rem:
8 ) 26 6
8) 3 2
0 3
Decimal to Octal Conversion
Example 2: 433010 = 103528
8 ) 4330 Rem:
8 ) 541 2
8 ) 67 5
8 ) 8 3
8 ) 1 0
0 1
Decimal to Octal Conversion
The Subtraction Method:
Subtract out multiples of the largest power of 8
possible (without going below zero) each time
until you reach 0.
Place the multiple value in each position
315 82 81 80
- 256 (4 x 64) 64 8 1
59 4 7 3
- 56 (7 x 8)
3
- 3 (3 x 1) Answer: 31510 = 4738
0
Decimal to Octal Conversion
Example 2: 201810
2018 84 83 82 81 80
-1536 (3 x 512) 4096 512 64 8 1
482 3 7 4 2
- 448 (7 x 64)
34
- 32 (4 x 8)
2
- 2 (2 x 1) Answer: 201810 = 37428
0
Hexadecimal (Hex)
Numbering System
Base: 16
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
(1 x 256) + (F x 16) + (4 x 1)
= (1 x 256) + (15 x 16) + (4 x 1)
7 = 111
4 = 100
2 = 010
111 100 010
7428 = 1111000102
Binary to Octal Conversion
Ex : Convert 101001102 to octal
Starting at the right end, split into groups of 3:
10 100 110
110 = 6
100 = 4
010 = 2 (pad empty digits with 0)
101001102 = 2468
Binary to Hex Conversion
The maximum value represented in 4 bit is:
24 – 1 = 15
1 1010 0110
0110 = 6
1010 = A
0001 = 1 (pad empty digits with 0)
1101001102 = 1A616
Hex to Binary Conversion
Ex : Convert 3D916 to binary
Convert each hex digit to 4 bits:
3 = 0011
D = 1101
9 = 1001
10101111012 to Hex
82F16 to Binary
(Answers on NEXT slide)
Answers
numbering system
Octal to Hex Conversion
Ex : Convert 7528 to hex
So 7528 = 1EA16
Hex to Octal Conversion
Ex : Convert E8A16 to octal
So E8A16 = 72128
Questions?
Why does Hexadecimal
Numbers used to represent
binary?
The hexadecimal system is commonly used by
programmers to describe locations in memory
because it can represent every byte (i.e., eight
bits) as two consecutive hexadecimal digits instead
of the eight digits that would be required by binary
(i.e., base 2) numbers and the three digits that
would be required with decimal numbers.
In addition, it is much easier for
humans to read hexadecimal
numbers than binary numbers, and
it is not much more difficult for
computer professionals to read
hexadecimal numbers than decimal
numbers.
END!