Sie sind auf Seite 1von 69

Computer

TOPIC

1
2.2 2.2.1 BINARY

NUMBER
SYSTEM 2.2.2 HEXADECIMAL
&
REPRESENTATION 2.2.3 CONVERSION BETWEEN
BINARY AND HEXADECIMAL
TOPIC

2
2.2 NUMBER SYSTEM & REPRESENTATION
2.2.1 Binary
2.2.2 Hexadecimal
2.2.3 Conversion Between Binary and
Hexadecimal
Learning Outcomes:
After this lesson, student should be able to:
(a)Represent data in binary form

Remarks:
Machine recognises two state: 0 and 1.
TOPIC

3
2.2.1 BINARY

Number System

A set of numerals for representing numbers

Example of number system:


Binary Numbers (base 2)
Decimal Numbers (base 10)
Hexadecimal Numbers (base 16)
TOPIC

4
2.2.1 BINARY

Decimal Numbers (Base 10)

Definition:
Number system base 10 that consists of numbers 0-9
(0,1,2,3,4,5,6,7,8,9)

Familiar use in everyday life


Decimal digits are joined together to form longer
decimal numbers
Example: 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12,
TOPIC

5
2.2.1 BINARY

Decimal Numbers (Base 10)


Also known as the base 10 numbering system

Example:
How 615 is represented in decimal numbers

10^2 10^1 10^0


6 1 5

6 x 100 1 x 10 5x1
TOPIC

600 + 10 + 5 = 61510

Always write the


base
6
2.2.1 BINARY

Binary Numbers (Base 2)


Definition:
Binary number is a number system with base 2 that use
binary digit 1 and 0.

Computer uses the binary digit (bit) 0 and 1


Bits 0 and 1 are joined together to form binary
numbers
Binary number represents numeric values using two
symbols 0 and 1
TOPIC

7
2.2.1 BINARY

Binary Numbers
Binary digit

1 1 02 Base
TOPIC

Binary number

8
DECIMAL BINARY
2.2.1 BINARY 0 0
1 1
2 10
3 11
Comparison 4 100
between 5 101
decimal numbers 6 110
and 7 111
binary numbers 8 1000
9 1001
10 1010
11 1011
12 1100
TOPIC

13 1101
14 1110
15 1111
16 10000
9
2.2.1 BINARY

Decimal to Binary conversion

Example 1:

Convert the number 2210 to the binary number


system

Solution:
Desired base is 2, so we repeatedly divide the given
TOPIC

decimal number by 2.

10
2.2.1 BINARY

Solution (repeatedly divide)


22
2
11
2 ---- 0
5
2 ---- 1
Binary
2
2 ---- 1 number
2 1 ---- 0
TOPIC

0 ---- 1 Hence, 2210 = 101102

11
2.2.1 BINARY

Example 2:
Convert the number 4010 to the binary
number system.

Solution:
Desired base is 2, so we repeatedly divide
the given decimal number by 2.
TOPIC

12
2.2.1 BINARY

Solution (repeatedly divide)


40
2
20
2 ---- 0
10
2 ---- 0 Binary
5 number
2 ---- 0
2 2 ---- 1
TOPIC

2 1 ---- 0
0 ---- 1
Hence, 4010 = 1010002
13
2.2.1 BINARY

Example 3

Express 1810 in binary number form

Solution:
Divide the given decimal number by 2.
TOPIC

14
2.2.1 BINARY

Solution
18
2
9
2 ---- 0
4
2 ---- 1
2 Binary
2 ---- 0
2 1 ---- 0 number
TOPIC

0 ---- 1
Hence, 1810 = 100102
15
2.2.1 BINARY

Binary to Decimal conversion

In binary number, the column weights


(again from right to left) are as follows:

(2^3) (2^2) (2^1) (2^0)


8 4 2 1
TOPIC

16
2.2.1 BINARY

Convert the binary number 101102 to decimal


number
Solution:

Example 1
2^4 2^3 2^2 2^1 2^0 2210
16 8 4 2 1
1 0 1 1 0
16 x 1 8x0 4x1 2x1 1x0
16 + 0+ 4+ 2+ 0=
TOPIC

Hence, 101102 = 2210


17
2.2.1 BINARY

Example 2
Convert the binary number 10111002 to decimal
number
Solution:

2^6 2^5 2^4 2^3 2^2 2^1 2^0 9210


1 0 1 1 1 0 0
64 x 1 32 x 0 16 x 1 8x1 4x1 2x0 1x0
64 + 0+ 16 + 8+ 4+ 0+ 0=
TOPIC

Hence, 10111002 = 9210

18
2.2.1 BINARY

Example 3
Convert the binary number 11101102 to decimal
number
Solution:
2^6 2^5 2^4 2^3 2^2 2^1 2^0 11810

1 1 1 0 1 1 0

64 x 1 32 x 1 16 x 1 8 x 0 4 x 1 2 x 1 1x0
64 + 32 + 16 + 0+ 4+ 2+ 0=
TOPIC

Hence, 11101102 = 11810

19
2.2 2.2.1 BINARY

2.2.2 HEXADECIMAL
NUMBER
SYSTEM
2.2.3 CONVERSION BETWEEN
& BINARY AND HEXADECIMAL
REPRESENTATION
TOPIC

20
2.2 NUMBER SYSTEM & REPRESENTATION
2.2.1 Binary
2.2.2 Hexadecimal
2.2.3 Conversion Between Binary and
Hexadecimal

Learning Outcomes:
After this lesson, student should be able to:
(a) Represent data in hexadecimal form
TOPIC

21
2.2.2 HEXADECIMAL

Hexadecimal Numbers

Uses 16 symbols: 0,1,2, 3, 4, 5, 6, 7, 8, 9, A, B,


C, D, E and F.
9B416 is example of hexadecimal numbers.
TOPIC

22
DECIMAL HEXADECIMAL
0 0
1 1
2 2
3 3
4 4
Comparison
5 5
between
6 6
decimal
7 7
numbers
8 8
and
9 9
hexadecimal 10 A
numbers 11 B
12 C
TOPIC

13 D
14 E
15 F
16 10
23
Hexadecimal Numbers
Hexadecimal Decimal Binary
Digit Equivalent Equivalent
0 0 0
1 1 1
2 2 10
3 3 11
4 4 100
5 5 101
6 6 110
7 7 111
8 8 1000
9 9 1001
A 10 1010
TOPIC

B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
24
2.2.2 HEXADECIMAL

Decimal to hexadecimal conversion


Example 1:

Convert the decimal number 134110 to hex number

Solution:
Desired base is 16, so we repeatedly divide the given
TOPIC

decimal number by 16.

25
2.2.2 HEXADECIMAL

A=10
Solution:
B=11
C=12
16 1341 D = 13
16 83---- 13
16 5 ---- 3
0 ---- 5 Hex Number
TOPIC

Hence,134110 = 53D16

26
2.2.2 HEXADECIMAL

Example 2

Convert the decimal number 86010 to hexadecimal


number

Solution:
Desired base is 16, so we repeatedly divide the given
TOPIC

decimal number by 16.

27
2.2.2 HEXADECIMAL

A=10
Solution
B=11
C=12
16 860 D = 13
16 53 ---- 12

16 ---- 5
3 Hex Number
TOPIC

0 ---- 3

Hence, 86010 = 35C16


28
2.2.2 HEXADECIMAL

Example 3

Convert the decimal number 202010 to hex number

Solution:
Desired base is 16, so we repeatedly divide the
given decimal number by 16.
TOPIC

29
2.2.2 HEXADECIMAL

Solution

16 2020
16
16

Hex Number
TOPIC

Hence, 202010 =
30
2.2.2 HEXADECIMAL

Hexadecimal to Decimal conversion

In hex number, the column weights (again from


right to left) are as follows:

(16^3) (16^2) (16^1) (16^0)


TOPIC

4096 256 16 1

31
2.2.2 HEXADECIMAL

Example 1

Convert AFB216 to decimal number


Solution:

16^3 16^2 16^1 16^0 4497810


4096 256 16 1
A (10) F (15) B (11) 2
TOPIC

4096 x 10 256 x 15 16 x 11 1x2


40960 + 3840 + 176 + 2=

Hence, AFB216 = 4497810


32
2.2.2 HEXADECIMAL

Example 2

Convert BA816 to decimal number


Solution:

16^2 16^1 16^0 298410


B (11) A (10) 8
256 x 11 16 x 10 1x8
2816 + 160 + 8=
TOPIC

Hence, BA816 = 298410


33
2.2.2 HEXADECIMAL

Example 3
Convert AFFA16 to decimal number
Solution:
16^3 16^2 16^1 16^0 4505010
A (10) F(15) F(15) A(10)
4096 x 10 256 x 15 16 x 15 1 x 10
40960 + 3840 + 240 + 10 =
TOPIC

Hence, AFFA16 = 4505010


34
2.2 2.2.1 BINARY

NUMBER 2.2.2 HEXADECIMAL

SYSTEM 2.2.3 CONVERSION BETWEEN


BINARY AND HEXADECIMAL
&
REPRESENTATION
TOPIC

35
2. NUMBER SYSTEM & REPRESENTATION
1. Binary
2. Hexadecimal
2.2.3 Conversion Between Binary and
Hexadecimal

Learning Outcomes:

After this lesson, student should be able to:


(a) Convert from binary to hexadecimal
TOPIC

(b) Convert from hexadecimal to binary

36
3. CONVERSION BETWEEN
BINARY AND HEXADECIMAL

Binary to Hexadecimal conversion


Long Solution:
Step 1 : Convert binary to decimal
Step 2 : Convert decimal to hexadecimal
Step 1 Step 2

Binary Decimal Hexadecimal


TOPIC

37
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Example 1:
Convert the binary number 110102 to hexadecimal.

Long Solution:
Step 1 Step 2

Binary Decimal Hexadecimal


TOPIC

38
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 1: Convert binary to decimal

Solution:
2^4 2^3 2^2 2^1 2^0 2610
1 1 0 1 0
16 x 1 8x1 4x0 2x1 1x0
16 + 8+ 0+ 2+ 0=
TOPIC

39
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 2: Convert decimal to hexadecimal:

Solution:

16 26
16 1 ---- 10-a
Hex number
0 ---- 1
TOPIC

Hence, 110102 = 1A16

40
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Convert the binary number 11010 to hexadecimal.


Use short solution:
23 22 21 20 23 22 21 20
8 4 2 1 8 4 2 1
Divide the
1 1 0 1 0
number into 4
1+ 8+ 0+ 2+ 0+ digit, from
right to left
1 10
TOPIC

1 A

Hence, 110102 = 1A16


41
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Convert the binary number 11010 to hexadecimal.


Use short solution:

20 23 22 21 20

1 1 0 1 0 Divide the number into 4 digit,


from right to left
TOPIC

1 8 + 2 = 10

Hence, 110102 = 1A16


42
3. CONVERSION BETWEEN
BINARY AND HEXADECIMAL

Example 2
Convert the binary number 100102
to hexadecimal.
TOPIC

43
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 1: Convert binary to decimal

Solution:
2^4 2^3 2^2 2^1 2^0 1810
1 0 0 1 0
16 x 1 8 x 0 4 x 0 2 x 1 1x0
16 + 0 + 0 + 2+ 0=
TOPIC

44
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 2: Convert decimal to hex:


Solution:

16 18
16 1 ---- 2
Hex number
0 ---- 1
TOPIC

Hence, 100102 = 1216

45
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Convert the binary number 10010 to hexadecimal.


Use short solution:
20 23 22 21 20

1 0 0 1 0

Divide the number into 4 digit,


from right to left
TOPIC

1 2
Hence, 100102 = 1216
46
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Example 3
Convert the binary number 11112 to
hexadecimal.
TOPIC

47
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 1: Convert binary to decimal


Solution:

2^3 2^2 2^1 2^0 1510


1 1 1 1
8x1 4x1 2x1 1x1
8+ 4+ 2+ 1=
TOPIC

48
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 2: Convert decimal to hex:


Solution:

16 15
0 ---- 15 Hex number
TOPIC

Hence, 11112 = F16

49
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Convert the binary number 1111 to hexadecimal.


Use short solution:

23 22 21 20

1 1 1 1 Divide the number into 4 digit,


from right to left

8 + 4 + 2 + 1 = 15
TOPIC

Hence, 11112 = F16


50
3. CONVERSION BETWEEN
BINARY AND HEXADECIMAL

Hexadecimal to Binary conversion

Step 1 : Convert hexadecimal to decimal

Step 2 : Convert decimal to binary


Binary Decimal Hexadecimal
TOPIC

Step 2 Step 1

51
3. CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Example 1
Convert the hexadecimal number 3FD to
binary number

Binary Decimal Hexadecimal


TOPIC

Step 2 Step 1

52
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 1: Convert hex to decimal

Solution:
16^2 16^1 16^0 102110
3 F D
256 x 3 16 x 15 1 x 13
768 + 240 + 13 =
TOPIC

53
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

2 1021 Step 2: Convert decimal to


2 510 ---- 1 binary
2 255 ---- 0
2 127 ---- 1
2 63 ---- 1
2 31 ---- 1 Binary number
2 15 ---- 1
2 7 ---- 1
TOPIC

2 3 ---- 1
2 1 ---- 1

0 ---- 1
Hence, 3FD16 = 11111111012
54
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL
Convert the hexadecimal number 3FD16 to binary number

Short Solution:
1. Divide the number
into single digit 3 F D
2. Divide each number
by 2
2 15 2 13
2 3 2 7 ---- 1 2 6 ---- 1
TOPIC

2 1 ---- 1 2 3 ---- 1 2 ---- 0


3
2 0 ---- 1 2 1 ---- 1 2 1 ---- 1
0 ---- 1 0 ---- 1

55
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

2. Divide each number by 2

15 13
2 2

7 2 6 ---- 1
2 3 2 ---- 1
2 1 ---- 1 2 3 2 3 ---- 0
---- 1
2 0 ---- 1 1 2 1 ---- 1
2 ---- 1
0 0 ---- 1
---- 1
TOPIC

11 1111 1101

56
Hence, 3FD16 = 11111111012
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL
Convert the hexadecimal number 3FD16 to binary number
Short Solution:
1. Divide the number
into single digit 3 F D
2. Create each hexadecimal number into 4 digit binary number

3 F (15) D (13)

23 22 21 20 23 22 21 20 23 22 21 20
8 4 2 1 8 4 2 1 8 4 2 1
TOPIC

0 0 x x x x 0 x
0 0 1 1 1 1 1 1 1 1 0 1

Hence, 3FD16 = 11111111012


57
3. CONVERSION BETWEEN
BINARY AND HEXADECIMAL

Example 2
Convert the hexadecimal number 1A216 to
binary number
TOPIC

58
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 1: Convert hex to decimal

Solution:

16^2 16^1 16^0 41810


1 A (10) 2
256 x 1 16 x 10 1x2
TOPIC

256 + 160 + 2=

59
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Solution: Step 2: Convert decimal to binary


2 418

2 209 ---- 0

2 104 ---- 1
2 52 ---- 0
26
Binary number
2 ---- 0
2 13 ---- 0
6
TOPIC

2 ---- 1
2 3
---- 0 Hence,
2 1 1A216 = 1101000102
---- 1
---- 1
60 0
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Convert the hexadecimal number 1A2 to binary


number
Short Solution:
1. Divide the number
into single digit:
1 A 2 Add to form 4 digit
2. Divide each number
by 2:

1 1 0 1 0 0 0 1 0
TOPIC

Hence, 1A216 = 1101000102


61
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL
Convert the hexadecimal number 1A216 to binary number

Short Solution:
1. Divide the number
into single digit
1 A 2
2. Create each hexadecimal number into 4 digit binary number
1 A (10) 2

23 22 21 20 23 22 21 20 23 22 21 20
8 4 2 1 8 4 2 1 8 4 2 1
TOPIC

1 1 0 1 0 0 0 1 0

Hence, 1A216 = 1101000102


62
3. CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Example 3

Convert the hexadecimal number


AF1 to binary number
TOPIC

63
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 1: Convert hex to decimal

Solution:

1
16^
1
25
TOPIC

64
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Step 2: Convert decimal to binary

350
Binary number

43
2
2 10
TOPIC

2
0

Hence, AF116 =
65
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL

Convert the hexadecimal number AF1 to binary


number
Short Solution:
1. Divide the number
into single digit: F
2. Divide each number Add to form 4 digit
by 2:
TOPIC

Hence, AF116 = 1010111100012


66
2.2.3 CONVERSION BETWEEN BINARY
AND HEXADECIMAL
Convert the hexadecimal number AF116 to binary number
Short Solution:

1. Divide the number


into single digit A F 1
2. Create each hexadecimal number into 4 digit binary number

23
8
TOPIC

Hence, AF116 =
67
Summary
Number system
Binary numbers
Decimal numbers
Hexadecimal numbers
Convert binary to hexadecimal
Convert hexadecimal to binary
TOPIC

68
Summary

Hexadecimal to Decimal to Binary conversion and vise


versa
16
2 power of number

Binary Decimal Hexadecimal


TOPIC

2 16 power of number

69