Week 4-Data Representation - Binary System
Week 4-Data Representation - Binary System
DATA REPRESENTATION,
BINARY SYSTEM, BIT,
BYTE, ASCII CODE
Objectives
2
The possibilities:
Decimal Octal
Binary Hexadecimal
Quick Example
10
Base
Decimal to Decimal (just for fun)
11
Decimal Octal
Binary Hexadecimal
Next slide…
Example
12
Weight
Base
Binary to Decimal
13
Decimal Octal
Binary Hexadecimal
Binary to Decimal
14
Technique
Multiply each bit by 2n, where n is the “weight” of the
bit
The weight is the position of the bit, starting from 0 on
the right
Add the results
Example
15
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
Octal to Decimal
16
Decimal Octal
Binary Hexadecimal
Octal to Decimal
17
Technique
Multiply each bit by 8n, where n is the “weight” of the
bit
The weight is the position of the bit, starting from 0 on
the right
Add the results
Example
18
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
19
Decimal Octal
Binary Hexadecimal
Hexadecimal to Decimal
20
Technique
Multiply each bit by 16n, where n is the “weight” of
the bit
The weight is the position of the bit, starting from 0 on
the right
Add the results
Example
21
Decimal Octal
Binary Hexadecimal
Decimal to Binary
23
Technique
Divide by two, keep track of the remainder
First remainder is bit 0 (LSB, least-significant bit)
Second remainder is bit 1
Etc.
Example
24
12510 = ?2 2 125
2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1
12510 = 11111012
Octal to Binary
25
Decimal Octal
Binary Hexadecimal
Octal to Binary
26
Technique
Convert each octal digit to a 3-bit equivalent binary
representation
Example
27
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
28
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary
29
Technique
Convert each hexadecimal digit to a 4-bit equivalent
binary representation
Example
30
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Class work
31