Full Transcript

The System unit Processing Lecture 05 By Ammara Gillani Data and Program Representation Digital Data Representation Coding Systems Used to represent data and programs in a manner understood by the computer Digital Computers Can only understand two states, off and on (0 an...

The System unit Processing Lecture 05 By Ammara Gillani Data and Program Representation Digital Data Representation Coding Systems Used to represent data and programs in a manner understood by the computer Digital Computers Can only understand two states, off and on (0 and 1) Digital Data Representation The process of representing data in digital form so it can be understood by a computer Digital Data Representation Bit The smallest unit of data that a binary computer can recognize (a single 1 or 0) Byte = 8 bits Byte terminology used to express the size of documents and other files, programs, etc. Prefixes are often used to express larger quantities of bytes: kilobyte (KB), megabyte (MB), gigabyte (GB), terabyte (TB), petabyte (PB), exabyte (EB), zettabyte (ZB), yottabyte (YB). Representing Numerical Data Numbering system A way of representing numbers Decimal numbering system Uses 10 symbols (0-9) Binary numbering system Uses only two symbols (1 and 0) to represent all possible numbers In both systems, the position of the digits determines the power to which the base number (such as 10 or 2) is raised Number Systems To a computer, everything is a number Numbers, letters, punctuation marks, sounds and pictures are numbers E.g. Consider the following sentence Here are some words. May look like a sequence of characters, but to a computer it looks like the string of ones and zeros as shown on next slide. Here are some words. H 0100 1000 e 0110 0101 r 0111 0010 e 0110 0101 0010 0000 a 0110 0001 r 0111 0010 e 0110 0101 0010 0000 s 0111 0011 o 0110 1111 m 0110 1101 e 0110 0101 0010 0000 w 0111 0111 o 0110 1111 r 0111 0010 d 0110 0100 s 0111 0011. 0010 1110 Number Systems Decimal Number System Binary Number System Octal Number System Hexadecimal Number System Decimal Number System In our day-to-day like we use decimal number system. In this system base is equal to 10 because there are altogether 10 symbols or digits: {0 1 2 3 4 5 6 7 8 9}. When we need to represent a number greater than 9, we use two symbols together as in 9 + 1 = 10 As the number starts to become longer, the concept of place becomes important. E.g. 1325₁₀ 1325 = (1 x 10³) + (3 x 10²) + (2 x 10¹) + (5 x 10⁰) Binary Number System In computers all data is represented by the state of computer’s electronic switches. Switch has only two possible values (ON or OFF). Represented by 2 numeric values When a switch is OFF represents 0, when it is ON represents 1. So the Base of Binary Number System is 2, can only use two digits 0 and 1. Each position in binary number represents a power of base (2). Conversion of Binary Number to Decimal Number Example: Decimal Equivalent of Binary Number 10101₂ is = (1x2⁴) + (0x2³) + (1x2²) + (0x2¹) + (1x2⁰) = 16 + 0 + 4 + 0 + 1 = 21₁₀ Example 2: 0101₂ = ( )₁₀ Conversion of Decimal Number to Binary Number Example: Convert 13 to base 2 2 13 2 6 ---- 1 2 3 ---- 0 1 ---- 1 (1101)₂ Example 2: 23₁₀ = ( )₂ Decimal Number Binary Number Decimal Equivalent of Binary 0 0000 Numbers 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 Octal Number System Base is 8 8 symbols: {0,1,2,3,4,5,6,7} Each place is weighted by the power of 8 Example: (345)₈ Octal Number Binary Number 0 0000 1 0001 Octal Equivalent of 2 0010 Binary Numbers 3 0011 4 0100 5 0101 6 0110 7 0111 Conversion from Octal to Decimal Example : (345)₈ =( )₁₀ = (3x8²) + (4x8¹) + (5x8⁰) = 192 + 32 + 5 = (229)₁₀ Conversion from Decimal to Octal Repeatedly Divide by 8 Example: (952)₁₀ = ( )₈ Conversion from Octal to Binary Expand each octal digit to 3 binary digits. Example: (725)₈ = (111 | 010 | 101)₂ Another method for converting an octal number to binary is by First, convert the octal number to a decimal number, and then convert the decimal number to its binary form. Example: (725)₈ = (469)₁₀ (469)₁₀ = (111010101)₂ Conversion from Binary to Octal Combine every 3 bits into one octal digit Example: (110 | 010 | 011)₂ = (623)₈ Hexadecimal Number System Base is 16 16 symbols: {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} Each place is weighted by the power of 16 Example: (3AB)₁₆ Conversion from Hexadecimal to Decimal Number (3AB4)₁₆ to Base 10 (3AB4)₁₆ = 3x16³+10x16²+11x16¹+4x 16⁰ = 12288 + 2560 + 176 + 4 = 15028 Conversion from Decimal Number to Hexadecimal Repeated Division by 16 e.g. (428)₁₀ = ()₁₆ Conversion from Hexadecimal to Binary Number Expand each hexadecimal digit to 4 binary digits. E.g. (E29)₁₆ = (1110 | 0010 | 1001)₂ Conversion from Binary Number to Hexadecimal Combine every 4 bits into one hexadecimal digit Example: (0101 | 1111 | 1010 | 0110)₂ = (5FA6)₁₆ Some Important Conversions to Remember Base 10 Base 2 Base 16 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 10 1010 A 11 1011 B 12 1100 C 13 1101 D 14 1110 E DSE, FBAS, IIUI 09/21/24 15 1111 F

Use Quizgecko on...
Browser
Browser