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 repre senting 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 consist ing of symbols can be expressed as: where, mywbut.com 1
21
Embed
Computer Number Systems, Approximation in Numerical Computation
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
8/6/2019 Computer Number Systems, Approximation in Numerical Computation
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 symbolsdenote 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
8/6/2019 Computer Number Systems, Approximation in Numerical Computation
For 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 andas 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
8/6/2019 Computer Number Systems, Approximation in Numerical Computation
digit 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.eand 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 thefloating - 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 pointnumbers.
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/6/2019 Computer Number Systems, Approximation in Numerical Computation
If 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 representingnumbers 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
8/6/2019 Computer Number Systems, Approximation in Numerical Computation
The most common computer arithmetic are integer arithmetic and floating point
arithmetic. Now these arithmetic systems will be briefly discussed.
Integer Arithmetic :
The result of any integer arithmetic operation is always an integer. The range of
integers that can be represented on a given computer is finite. The result of an integer
division is usually given as a quotient. The remainder is truncated as fractionalquantities which cannot be represented under the integer representation.
Eg:
Remark:
(1) Simple rules like , where are integers may not hold
under computer integer arithmetic due to the truncation of the remainder.
(2) An integer operation may result in a very small or a very large number which is
beyond the range of that the computer can handle. When the result is larger than the
maximum limit , it is referred to as an overflow and when it is less than the lower limit , it
is referred to as underflow.
mywbut.com
8/6/2019 Computer Number Systems, Approximation in Numerical Computation
Numerical errors arise during computations due to round-off errors and truncation
errors.
Round-off Errors:
Round-off error occurs because computers use fixed number of bits and hence fixed
number of binary digits to represent numbers. In a numerical computation round-off
errors are introduced at every stage of computation. Hence though an individualround-off error due to a given number at a given numerical step may be small but the
cumulative effect can be significant.
When the number of bits required for representing a number are less then the number
is usually rounded to fit the available number of bits. This is done either by chopping or
by symmetric rounding.
Chopping : Rounding a number by chopping amounts to dropping the extra digits. Here
the given number is truncated. Suppose that we are using a computer with a fixed word
length of four digits. Then the truncated representation of the number will be
. The digits will be dropped. Now to evaluate the error due to chopping let us
consider the normalized representation of the given number i.e.
chopping error in representing .
So in general if a number is the true value of a given number and is the
normalized form of the rounded (chopped) number and is the
mywbut.com
8/6/2019 Computer Number Systems, Approximation in Numerical Computation