
www.getmyuni.com Computer Representation of Numbers and Computer Arithmetic In a Computer numbers are represented by binary digits 0 and 1. Computers employ binary arithmetic for performing operations on numbers. Since it gets cumbersome to display large numbers in binary form computers usually display them in hexadecimal or octal or decimal system. All of these number systems are positional systems. In a positional system a number is represented by a set of symbols. Each of these symbols denote a particular value depending on its position. The number of symbols used in a positional system depends on its 'base'. Let us now discuss about various positional number systems: Decimal System: The decimal system uses 10 as its base value and employs ten symbols 0 to 9 in representing numbers. Let us consider a decimal number 7402 consisting of four symbols 7,4,0,2. In terms of base 10 it can be expressed as follows. So each of the symbols from a set of symbols denoting a number is multiplied with power of the base (10) depending on its position counted from the right. The count always begins with 0. In general a decimal number consisting of symbols can be expressed as: where, mywbut.com 1 www.getmyuni.com Similarly, a fractional part of a decimal number can be expressed as Binary system: Binary system is the positional system consisting of two symbols i.e. 0,1 and '2' as its base. Any binary number actually represents a decimal value given by where Consider the binary number 10101. The decimal equivalent of 10101 is given by Hexadecimal System: The Hexadecimal system is the positional system consisting of sixteen symbols, 0,1,2...9,A,B,C,D,E,F, and '16' as its base. Here the symbols A denotes 10, B denotes 11 and so on. The decimal equivalent of the given hexadecimal number is given by . For example consider . We can convert a binary number directly to a hexadecimal number by grouping the binary digits, starting from the right, into sets of four and converting each group to its equivalent hexadecimal digit. If in such a grouping the last set falls short of four binary digits then do the obvious thing of prefixing it with adequate number of binary digit '0'. mywbut.com 2 www.getmyuni.comFor example let us find the hexadecimal equivalent of The vice-versa is also true. Octal System: The octal system is the positional system that uses 8 as its base and as its symbol set of size 8. The decimal equivalent of an octal number is given by . For example consider We can get the octal equivalent of a binary number by grouping the binary digits, starting from the right, into sets of three binary digits and converting each of these sets to its octal equivalent. If such a grouping results in a last set having less number of digits it may be prefixed with adequate number of binary digit 0. As an example the octal equivalent of Conversion of decimal system to non-decimal system: To convert a decimal number to a number of any other system we should consider the integer and fractional parts separately and follow the following procedure: Conversion of integer part: (a) Consider the integer part of a given decimal number and divide it by the base b of the new number system. The remainder will constitute the rightmost digit of the integer mywbut.com 3 www.getmyuni.compart of the new number. (b) Next divide the quotient again by the base b. The remainder will constitute second digit from the right in the new system. Continue this process until we end up with a zero-quotient. The last remainder is the leftmost digit of the new number. Conversion of fractional part: (a) Consider the fractional part of the given decimal number and multiply it with the base b of the new system. The integral part of the product constitutes the leftmost digit of the fractional part in the new system. (b) Now again multiply the fractional part resulting in step (a) by the base b of the new system. The integral part of the resultant product is the second digit from the left in the new system. Repeat the above step until we encounter a zero-fractional part or a duplicate fractional part. The integer part of this last product will be the rightmost digit of the fractional part of the new number. Eg: Convert 54.45 into its binary equivalent. (a) Consider the integer part i.e. 54 and apply the steps listed under conversion of integer part i.e. (b) Conversion of fractional part: Product integral partBinary number mywbut.com 4 www.getmyuni.com 0.45 2 =0.90 0 0.9 2 =1.80 1 0.8 2 =1.6 1 0.6 2 =1.2 1 0.2 2 =0.4 0 0.4 2 =0.8 0 0.8 2 =1.6 1 0.6 2 =1.2 1 0.2 2 =0.4 0 0.4 2 =0.8 0 0.8 2 =1.6 1 Here the overbar denotes the repetition of the binary digits. Note: Using binary system as an intermediate stage we can easily convert octal numbers to hexadecimal numbers and vice-versa. mywbut.com 5 www.getmyuni.com In the above two examples we have grouped the binary digits suitably either to quadruplets or triplets to convert octal to hexadecimal and hexadecimal to octal numbers respectively. mywbut.com 6 www.getmyuni.com Computer Representation of Numbers Computers are designed to use binary digits to represent numbers and other information. The computer memory is organized into strings of bits called words of same length. Decimal numbers are first converted into their binary equivalents and then are represented in either integer or floating point form. Integer Representation The largest decimal number that can be represented , in binary form , in a computer depends on its word length. An n-bit word computer can handle a number as large as . For instance a 16-bit word machine can represent numbers as large as . How do we represent negative numbers ? Negative numbers are stored using complement. This is obtained by taking the complement of the binary representation of the positive number and then adding to it. For example let us represent in the binary form. Here in an extra zero to the left of the binary number is appended to indicate that it is positive. If this extra leftmost binary digit is set to then it indicates that the binary number is negative. So the general convention for storing signed numbers is to append a binary mywbut.com 7 www.getmyuni.comdigit 0 or to the left of the binary number depending on the positive or negative sign of the number. So in a n-bit word computer, as one bit is reserved for sign , one can use maximum up to bits to store a signed number. So the largest signed number a 16-bit word can represent is . On this machine since zero is defined as it is redundant to use the number to define a "minus zero". It is usually employed to represent an additional negative number i.e and hence the range of signed numbers that can be represented on a 16-bit word machine is from to . Floating Point Representation Fractional numbers such as and large numbers like which fall outside the range of a d-bit word machine , say for instance 16-bit word machine are stored and processed in Exponential form. In exponential form these numbers have an embedded decimal point and are called floating point numbers or real numbers. The floating point representation of a real number is where is called mantissa and is the exponent. So the floating - point representation of the fractional number is and that of the large number is . Typically computers use a 32-bit representation for a floating point. The left most bit is reserved for the sign. The next seven bits are reserved for exponent and the last twenty four bits are used for mantissa. The shifting of the decimal point to the left of the most significant digit is called normalization and the numbers represented in the normalized form are known as normalized floating point numbers. For example , the normalized floating point form of the numbers , , are: 0.00695 = = .695E-2 56.2547 = = .562547E2 -684.6 = = -.6846E3 Inherent Errors Inherent errors arise due to the data errors or due to the conversion errors. Data Errors mywbut.com 8 www.getmyuni.comIf the data supplied for a problem is obtained from some experiment or from some measurement then it is prone to errors due to the limitations in instrumentation or reading. Such errors are also referred to as empirical errors. So when the data supplied is correct , say to two decimals there is no use performing arithmetic accurate to four decimals! Conversion Errors Conversion errors arise due to the limitation on the number of the bits used for representing numbers both under integer and floating point representation. So it is also called as representation error. The digits that are not retained constitute the round-off error. For example consider the case of representing a decimal number in a computer. The binary equivalent of has a non-terminating form like ...... but the computer has limited number of bits. If we add ten such numbers in a computer the result will not be exactly due to the round -off error during the conversion of to binary form. mywbut.com 9 www.getmyuni.com Computer Arithmetic The most common computer arithmetic are integer arithmetic and floating point arithmetic.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages21 Page
-
File Size-