🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Number System and Code conversion.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Document Details

Thapar Institute of Engineering and Technology

Tags

number systems computer architecture digital electronics

Full Transcript

Computer Architecture and Organization (ULC303) Number System and Code Conversion THAPAR INSTITUTE OF ENGINEERING & TECHNOLOGY...

Computer Architecture and Organization (ULC303) Number System and Code Conversion THAPAR INSTITUTE OF ENGINEERING & TECHNOLOGY Course Instructor Dr. Aditya Gupta Number Systems and Counting Computers and other digital systems process information as their primary function. Therefore, it is necessary to have methods and systems for representing information in different forms that can be easily manipulated and stored using electronic devices or other hardware. Number systems are mathematical systems for expressing quantities. Or “A system of counting” Or It is a mathematical notation for representing numbers of a given set consistently using digits or symbols. Understanding number systems is foundational for various fields like computer science, electrical engineering, and information technology. 8/3/2024 Thapar Institute of Engineering & Technology Types of Number Systems Roman number system: A numeral system that originated in ancient Rome and uses different Roman numerals such as I, II, III, IV, V, VI, VII, VIII, IX, and X to represent 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 respectively. 8/3/2024 Thapar Institute of Engineering & Technology Unary number system A numeral system that uses only a single digit to represent numbers. Numbers 1, 2, 3, 4, 5, 6,... are represented in unary as 1, 11, 111, 1111, 11111, 111111. 8/3/2024 Thapar Institute of Engineering & Technology Decimal number system The most commonly used number system in everyday life. It uses ten digits from 0 to 9. 8/3/2024 Thapar Institute of Engineering & Technology Binary number system The simplest and most fundamental number system used in digital electronics and computing. It uses only two symbols, 0 and 1. 8/3/2024 Thapar Institute of Engineering & Technology Octal number system A base-8 number system using digits 0 to 7. It’s often used as a shorthand notation for binary numbers because one octal digit represents three binary digits. Hexa Decimal number system A base-16 number system using digits 0 to 9 and letters A to F. It’s widely used in computing because one hexadecimal digit represents four binary digits, making it compact and easier to read. 8/3/2024 Thapar Institute of Engineering & Technology Radix/base of a number The radix or base of a number system is the number of unique digits, including zero, used to represent numbers in that system. It determines the positional value of each digit in a number. Positional Notation N = (an-1an-2... a1a0. a-1a-2... a-m)r where. = radix point r = radix or base n = number of integer digits to the left of the radix point m = number of fractional digits to the right of the radix point an-1 = most significant digit (MSD) a-m = least significant digit (LSD) 8/3/2024 Thapar Institute of Engineering & Technology Comparison of different number systems Decimal Binary Octal Hexadecimal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 Radix of different numeral systems: 100 4 4 5 101 5 5 Decimal = 10 6 110 6 6 Binary= 2 7 111 7 7 Octal=8 8 1000 10 8 Hexa Decimal=16 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 1 F 16 10000 20 10 8/3/2024 Thapar Institute of Engineering & Technology Conversion Among Bases The possibilities: Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example (25)10 = 110012 = 318 = 1916 Base 8/3/2024 Thapar Institute of Engineering & Technology Binary to decimal 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 Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example Bit “0” (101011)2 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 (43)10 8/3/2024 Thapar Institute of Engineering & Technology Exercise Q1 (11100000)2 = (?)10 Q2 (11101001)2 = (?)10 8/3/2024 Thapar Institute of Engineering & Technology Solutions Q1 (11100000)2 = (224)10 Q2 (11101001)2 = (233)10 8/3/2024 Thapar Institute of Engineering & Technology Octal to Decimal Technique n – Multiply each bit by 8 , 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 Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example (724)8 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 (468)10 8/3/2024 Thapar Institute of Engineering & Technology Exercise Q1 (77)8 = (?)10 Q2 (107)8 = (?)10 8/3/2024 Thapar Institute of Engineering & Technology Solutions Q1 (77)8 = (63)10 Q2 (107)8 = (71)10 8/3/2024 Thapar Institute of Engineering & Technology Hexadecimal to Decimal Technique n – Multiply each bit by 16 , 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 Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example (ABC)16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 (2748)10 (A2F)16 => (2607)10 8/3/2024 Thapar Institute of Engineering & Technology Hexadecimal to Binary Technique – Convert each hexadecimal digit to a 4-bit equivalent binary representation Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example (10AF)16 = (?)2 1 0 A F 0001 0000 1010 1111 (10AF)16 = (0001000010101111)2 8/3/2024 Thapar Institute of Engineering & Technology Decimal to Binary Technique – Divide by two, keep track of the remainder – First remainder is bit 0 (LSB, least-significant bit) – Second remainder is bit 1 – Etc. Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example (125)10 = (?)2 2 125 2 62 1 2 31 0 15 1 2 7 1 2 2 3 1 2 1 1 0 1 (125)10 = (1111101)2 8/3/2024 Thapar Institute of Engineering & Technology Octal to Binary Technique – Convert each octal digit to a 3-bit equivalent binary representation Decimal Octal Binary Hexadecimal 8/3/2024 Thapar Institute of Engineering & Technology Example (705)8 = (?)2 7 0 5 111 000 101 (705)8 = (111000101)2 8/3/2024 Thapar Institute of Engineering & Technology Octal to Hexadecimal (132) 8 = (?) 16 Octal Binary Hex 0010110102 = 5 A 16 1 3 2 0101 1 010 8/3/2024 Thapar Institute of Engineering & Technology Fractions Binary to decimal Decimal to binary (10.1011)2 => 1 x 2-4 = 0.0625 (8.25)10 => 0.25 x 2 = 0.50 1 x 2-3 = 0.125 0.50 x 2 = 1.00 0 x 2-2 = 0.0 1 x 2-1 = 0.5 0 x 20 = 0.0 (1000.01)2 1 x 21 = 2.0 (2.6875)10 8/3/2024 Thapar Institute of Engineering & Technology Exercise ( 31.4)10 = (?)2 (11111.0110)2 8/3/2024 Thapar Institute of Engineering & Technology Any random base (23.31)4 = (?)7 Step 1: Convert from base r to decimal. Step 2: Convert from decimal to the required base. (23.31)4 = (11.8125)10 = (14.5454)7 8/3/2024 Thapar Institute of Engineering & Technology Exercise – Convert... Hexa- Decimal Binary Octal decimal 33 1110101 703 1AF 8/3/2024 Thapar Institute of Engineering & Technology Hexa- Decimal Binary Octal decimal 33 100001 41 21 117 1110101 165 75 451 111000011 703 1C3 431 110101111 657 1AF 8/3/2024 Thapar Institute of Engineering & Technology Common Powers (1 of 2) Base=10 Power Preface Symbol Value 10-12 pico p.000000000001 10-9 nano n.000000001 10-6 micro .000001 10-3 milli m.001 103 kilo k 1000 106 mega M 1000000 109 giga G 1000000000 1012 tera T 1000000000000 8/3/2024 Thapar Institute of Engineering & Technology Common Powers (2 of 2) Base = 2 Power Preface Symbol Value 210 kilo k 1024 220 mega M 1048576 230 Giga G 1073741824 In computing, particularly with respect to memory, the base-2 interpretation generally applies 8/3/2024 Thapar Institute of Engineering & Technology Review – multiplying powers For common bases, add powers ab  ac = ab+c 26  210 = 216 = 65,536 or… 26  210 = 64  210 = 64k 8/3/2024 Thapar Institute of Engineering & Technology Binary Addition (1 of 2) Given two 1-bit values A B A+B 0 0 0 0 1 1 1 0 1 1 1 10 “two” 8/3/2024 Thapar Institute of Engineering & Technology Binary Addition (2 of 2) Two n-bit values – Add individual bits – Propagate carries – E.g., 1 1 10101 21 + 11001 + 25 101110 46 8/3/2024 Thapar Institute of Engineering & Technology Binary Subtraction Given two 1-bit values A B A-B Borrow 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 8/3/2024 Thapar Institute of Engineering & Technology Two n-bit values 101000 40 - 100111 -39 000001 01 8/3/2024 Thapar Institute of Engineering & Technology

Use Quizgecko on...
Browser
Browser