
DATA REPRESENTATION :NUMBER SYSTEMS Introduction to Number Systems In order to represent the characters on the keyboard(letter, numbers, special symbols, function keys etc) a coding systm is used. Each character is mapped onto the sysytem ucing ASCII or UNICODE. So for example the letter ‘A’ on the keyboard is represented as 65 in decimal and then this is converted to equivalent binary number to be stored on the computer. So we need to study the various number systems used to represent data in a computer. A number system is a method to represent (write) numbers. Every number system has a set of unique numbers or constants. The total count of the unique numbers is the base of the number system. There are basically four number systems which we need to study. Number Systems Decimal Binary Octal Hexadecimal Decimal Number System: Decimal Number system composed of 10 numerals or symbols. These numerals are 0 to 9. Using these symbols as digits we can express any quantity. It is also called base-10 system. It is a positional value system in which the value of a digit depends on its position. These digits can represent any value, for example: consider the number: 754. The value is formed by the sum of each digit, multiplied by the base (in this case it is 10 because there are 10 digits in decimal system) in power of digit position (counting from zero): Binary Number System: In Binary Number system there are only two digits i.e. 0 or 1. It is base-2 system. It can be used to represent any quantity that can be represented in decimal or other number system. It is a positional value system, where each binary digit has its own value or weight expressed as power of 2. The following are some examples of binary numbers: 1011012 112 101102 Octal Number System: It has eight unique symbols i.e. 0 to 7. It has base of 8. Each octal digit has its own value or weight expressed as a power of 8. Hexadecimal Number System: The hexadecimal system uses base 16. It has 16 possible digit symbols. It uses the digits 0 through 9 plus the letters A,B,C,D,E,F as 16 digit symbols. Each hexadecimal digit has its own value or weight expressed as a power of 16. To convert between the various number systems we need to create a simple table of values with nos representing equivalent digits in various number systems. Table to remember Decimal Binary Hexadecimal Octal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 8 1000 8 10 9 1001 9 11 10 1010 A 12 11 1011 B 13 12 1100 C 14 13 1101 D 15 14 1110 E 16 15 1111 F 17 Number Conversions We shall now study how conversions between the various number systems take place. Conversion from Decimal to other Number Systems We can represent a decimal number in any other number system (binary, octal or hexadecimal), by simply converting it to the required format. The following steps can be followed for the same: Step 1: Divide the decimal number by the base value of the number system in which it is to be converted (i.e.. 2 for binary, for octal and 16 for hexadecimal) Step 2: Store the remainder of division at each step Step 3: Keep on dividing the quotient by the base value till the quotient is zero Step 4: Now write the remainders(numbers) in the reverse order (from bottom to top) to form the equivalent number in the required base. Decimal to Binary conversion Since the binary number system is of base 2 so we keep on dividing the given decimal number by 2 till the quotient becomes 0. Example : To convert 45 to equivalent binary number (45)10 = (?)2 Qoutient Qoutient/2 Remainder 45 45/2 1 Read the numbers from bottom to 22 22/2 0 top i.e. from Most Significant 11 11/2 1 Bit(MSB) to Least Significant Bit 5 5/2 1 (LSB) 2 2/2 0 1 1/2 1 0 So the answer is : 101101 We can say that (45)10 = (101101)2 Decimal to Octal conversion Since the Octal number system is of base 8 so we keep on dividing the given decimal number by 8 till the quotient becomes 0. Example : To convert 65 to equivalent octal number (65)10 = (?)8 Qoutient Qoutient/8 Remainder 65 65/8 1 Read the numbers from bottom to 8 8/8 0 top i.e. from Most Significant 1 1/8 1 Bit(MSB) to Least Significant Bit 0 (LSB) So the answer is : 101 We can say that (65)10 = (101)8 The following table shows the equivalent octal number for decimal numbers from 1 to 15 Decimal Octal 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 10 9 11 10 12 11 13 12 14 13 15 14 16 15 17 Decimal to Hexadecimal conversion Since the Hexadecimal number system is of base 16 so we keep on dividing the given decimal number by 16 till the quotient becomes 0. However in the hexadecimal number system , the numbers from 10 to 15 are represented by albhabets A through F. Consider the following table: Decimal Hexadecimal 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 A 11 B 12 C 13 D 14 E 15 F Example : To convert 65 to equivalent hexadecimal number (65)10 = (?)16 Qoutient Qoutient/16 Remainder Read the numbers from bottom to 65 65/16 1 top i.e. from Most Significant 4 4/16 4 Bit(MSB) to Least Significant Bit 0 (LSB) So the answer is : 41 We can say that (65)10 = (41)16 Lets do another example: (45)10 = (?)16 Qoutient Qoutient/16 Remainder 45 45/16 13 The equivalent of 13 is D in base 2 2/16 2 16, so the number is 2D 0 Answer : 2D Converting decimal fractions to other number systems For this we need to follow the following steps: Step 1: Multiply the fractional part by the base value of the reqired equivalent number system. Step 2: store the integer part of the product achieved Step 3: Keep on repeating the above till the fractional part becomes 0 or upto a given number of decimal places, if it is a recurring fraction e.g, 0.33 Step 4: Read the number from top to bottom. Converting decimal fraction to binary We multiply the fractional part with 2 untill th fractional part becomes 0. Example: Let’s convert 0.625 to binary (0.625)10 = (?)2 Fractional part x 2 Product Integer part 0.625*2 1.250 1 0.250*2 0.500 0 0.500*2 1.000 1 Therefore (0.625)10 = (0.101)2 Converting decimal fraction to Octal We multiply the fractional part with 8 until the fractional part becomes 0. Example: Let’s convert 0.425 to octal (0.425)10 = (?)8 Fractional part x 8 Product Integer part 0.425*8 3.4 3 0.4*8 3.2 3 This calculation will not give o 0.2*8 1.6 1 in the fractional part so we stop 0.6*8 4.8 4 after having upto 4 digits(depends on question Therefore (0.425)10 = (0.3314)8 also) Uptill 4 decimal places. Converting decimal fraction to Hexadecimal We multiply the fractional part with 16 until the fractional part becomes 0. Example: Let’s convert 0.425 to Hexadecimal (0.425)10 = (?)16 Fractional part x 16 Product Integer part 0.42516 6.8 6 0.8*16 12.8 12=C This calculation will not give 0 0.8*16 12.8 12=C in the fractional part so we stop 0.8*16 12.8 12=C after having upto required number of didgits Therefore (0.425)10 = (0.6CCC)8 Uptil 4 decimal places. Converting from other number systems to decimal This requires obtaining the positional values of digits in a number. Step 1: Write down the digits of the given number Step 2: Multiply each digit with its positional value(d x base positional unit) Step 3: Add up the values . Step 4: The sum is the decimal equivalent of the given number Binary to Decimal Conversion Let us convert the binary number 110011 to its equivalent decimal number. Binary Digit 1 1 0 0 1 1 Base positional unit 25 24 23 22 21 20 d x bp 1x25 1 x 24 0 x 23 0 x 22 1 x 21 1 x 20 Positional 32 16 0 0 2 1 Value To obtain the decimal number, we add up the values: 32+16+0+0+2+1=51 Therefore : (110011)2 = (51)10 For fractional binary numbers we can extend the same to the right of the decimal number with base raised to -1, -2 etc. Example : Let us convert 1100.11 to equivalent decimal number: Binary Digit 1 1 0 0 . 1 1 Base positional 23 22 21 20 . 2-1 2-2 unit d x bp 1x23 1 x 22 0 x 21 0 x 20 . 1 x 2-1 1 x 2-2 Positional 8 4 0 0 0.5 0.25 Value Thus the equivalent decimal number will be : 8+4+0+0+0.5+0.25=12.75 Octal to Decimal Conversion Let us convert the octal number 56.24 to its equivalent decimal number Octal Digit 5 6 .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages14 Page
-
File Size-