2 0 COMPUTER SYSTEM 2 2 Number System
2. 0 COMPUTER SYSTEM 2. 2 Number System and Representation Prepared by Illa Iza Suhana Shamsuddin | Computer Science Unit
Learning Outcome At the end of this topic, students should be able to: 2. 2. 1 Binary • Represent data in binary form 2. 2. 2 Hexadecimal • Represent data in hexadecimal form 2. 2. 3 Conversion between binary and hexadecimal • Convert from binary to hexadecimal • Convert from hexadecimal to binary 2
Introduction Numbering System Concept A numbering system is a way of representing numbers. Common numbering system used is called the decimal numbering system / base 10 numbering system Exp: 2310 The decimal numbering system is the numbering system that represents all numbers using 10 symbols (0 – 9). 3
Binary Numbering System 2. 2. 1 Concept The numbering system that has just two unique digits, 0 and 1, called bits. Exp: 10102 0 1 0000 0001 2 3 4 5 0010 0011 0100 0101 6 7 8 9 0110 0111 1000 1001 4
2. 2. 1 Binary Numbering System Why? Computer uses the binary numbering system to represent the electronic status of the bits in memory. It also is used for other purposes such as addressing the memory locations. 5
2. 2. 2 Hexadecimal Numbering System Concept The numbering system that uses 16 different symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). Exp: 53 D 16 6
2. 2. 2 Hexadecimal Numbering System Why? Hexadecimal notation is a shorthand method for representing the binary digits stored in a computer. e. g. : • 11001001101000012 – can easily be misread by people, • hexadecimal notation groups binary digits into units of four, which in turn are represented by other symbols; i. e. C 9 A 116 7
Hexadecimal Symbol Decimal Equivalent 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 A 10 B 11 C 12 D 13 E 14 F 15 Binary Equivalent 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 8
2. 2. 3 Conversion Between Binary and Hexadecimal 1. Decimal to Binary 2. Binary to Decimal 3. Decimal to Hexadecimal 4. Hexadecimal to Decimal 5. Binary to Hexadecimal 6. Hexadecimal to Binary 9
1. Decimal to Binary - (base 10 to base 2) • Division – Remainder Method (Divide by 2, find the remainder) (2) Convert 15610 to binary (1) Convert 2310 to binary 2 23 2 11 2 5 2 2 2 1 0 1 1 1 0 1 Ans : 101112 *Read the remainder from below 2 2 2 2 156 78 0 39 0 19 1 4 1 2 0 1 0 0 1 Ans : 100111002 10
1. Decimal to Binary - (base 10 to base 2) • Division – Remainder Method (Divide by 2, find the remainder) Try this: Convert 5610 to binary 11
2. Binary to Decimal - (base 2 to base 10) • Place Value Method e. g. Convert 111012 to decimal Place value Step 1 Step 2 1 X 16 (24 ) 1 X 8 (23 ) 1 X 4 (22) 0 X 2 (21) Step 3 16 + 8 + 4 + 0 + = 2910 1 X 1 (20) 1 12
2. Binary to Decimal - (base 2 to base 10) • Place Value Method Try this: Convert 1100112 to decimal Step 1 Step 2 Step 3 13
3. Decimal to Hexadecimal - (base 10 to base 16) • Division – Remainder Method (Divide by 16, find the remainder) e. g. Convert 7710 to hex 16 77 16 4 0 13 = D 4 Read the remainder as hex number = 4 D 16 14
3. Decimal to Hexadecimal - (base 10 to base 16) • Division – Remainder Method (Divide by 16, find the remainder) Try this: Convert 9110 to hex 15
4. Hexadecimal to Decimal - (base 16 to base 10) • Place Value Method e. g. Convert 4 D 16 to decimal Step 1 Step 2 Step 3 4 4 X 16 (161) D 13 X 1 (160) Step 4 64 + 13 Decimal equivalent Place value = 7710 16
4. Hexadecimal to Decimal - (base 16 to base 10) • Place Value Method Try this: Convert AF 1016 to decimal Step 1 Step 2 Step 3 Step 4 17
5. Binary to Hexadecimal - (base 2 to base 16) • Step 1: Convert Binary to Decimal Place value method • Step 2: Convert Decimal to Hex Division – Remainder Method (Divide by 16, find the remainder) 18
5. Binary to Hexadecimal - (base 2 to base 16) Step 1: Place Value Method e. g. Convert 101012 to decimal Place Value Step 1 Step 2 1 0 X X 16 8 4 2 (24 ) (23 ) (22) (21) Step 3 16 + 0 + 4 + 0 + 1 X 1 (20) 1 = 2110 19
5. Binary to Hexadecimal - (base 2 to base 16) Step 2: Division – Remainder Method (Divide by 16, find the remainder) e. g. Convert 2110 to hex 16 21 16 1 5 0 1 Read the remainder as hex number = 1516 20
5. Binary to Hexadecimal - (base 2 to base 16) Try this: Convert 111010012 to hex 1. Step 1 ? 2. Step 2 ? 21
5. Binary to Hexadecimal - (simplify method) • 4 Bits = 1 Hex digit e. g. Convert 10101111012 to hex Group to 4 bits (R to L) Place value Decimal equivalent Hex equivalent Step 1 Step 2 Step 3 Step 4 0010 8421 2 2 1011 8421 11 B 1101 8421 13 D = 2 BD 16 22
6. Hexadecimal to Binary - (base 16 to base 2) • Step 1: Convert Hexadecimal to Decimal Place Value Method • Step 2: Convert Decimal to Binary Division – Remainder Method (Divide by 2, find the remainder) 23
6. Hexadecimal to Binary - (base 16 to base 2) Step 1: Place Value Method e. g. Convert F 116 to decimal Step 1 Step 2 Step 3 F 15 X 16 (161) Step 4 240 + 1 1 X 1 (160) 1 Decimal equivalent Place Value = 24110 24
6. Hexadecimal to Binary - (base 16 to base 2) Step 2: Division – Remainder Method (Divide by 2, find the remainder) e. g. Convert 24110 to binary *Read the remainder from below = 111100012 2 241 2 120 2 60 2 30 2 15 2 7 2 3 2 1 0 0 0 1 1 25
6. Hexadecimal to Binary - (base 16 to base 2) Try this: Convert 1 E 16 to binary 1. Step 1 ? 2. Step 2 ? 26
6. Hexadecimal to Binary - (simplify method) • 1 Hex digit = 4 Bits e. g. Convert 9 AF 16 to binary Break up each digit Decimal equivalent Place value Group all digits Step 1 Step 2 Step 3 Step 4 9 9 8421 1001 A 10 8421 1010 F 15 8421 1111 = 1001101011112 27
TO BASE FROM BASE 2 (Binary) - 10 (Decimal) Place Value Method 16 (Hexadecimal) Simplify Method (4 Bits = 1 Hex digit) 28
TO BASE FROM BASE 16 (Hexa decimal) 2 (Binary) Simplify Method (1 Hex digit = 4 Bits) 10 (Decimal) 16 Place Value Method - 29
TO BASE FROM BASE 10 (Decimal) 2 (Binary) 10 (Decimal) 1. Division – Remainder Method (Divide by 2, find the remainder) 16 (Hexadecimal) 1. Division – Remainder Method (Divide by 16, find the remainder) - – 30
TRY This… • Convert hexadecimal AF 1 to binary number. 16
TRY This… • Express 40 in binary number. 10
TRY This… • Convert the decimal number 860 to hexadecimal number. 10
TRY This… • Convert 11010101 to hexadecimal number. 2
- Slides: 34