Numerical Analysis Chapter 2
Numerical Analysis Chapter 2
1
The number 4728 means four thousands, seven hundreds, two tens, plus eight:
4728 = (4 * 1000) + (7 * 100) + (2 * 10) + 8
The decimal system is said to have a base, or radix, of 10. This means that each digit in the number
is multiplied by 10 raised to a power corresponding to that digit’s position:
83 = (8 * 101 ) + (3 * 100 )
4728 = (4 * 103 ) + (7 * 102 ) + (2 * 101 ) + (8 * 100).
The same principle holds for decimal fractions but negative powers of 10 are used. Thus,
the decimal fraction 0.256 stands for 2 tenths plus 5 hundredths plus 6 thousandths:
0.256 = (2 * 10-1 ) + (5 * 10-2 ) + (6 * 10-3 )
A number with both an integer and fractional part has digits raised to both positive and
negative powers of 10:
472.256 = (4 * 102) + (7 * 101 ) + (2 * 100 ) + (2 * 10-1 ) + (5 * 10-2 ) + (6 * 10-3 )
In general, for the decimal representation of the value of X = {…d2d1d0.d-1 d-2 d-3…}, the value of
X is ∑i(di x10i).
The Binary System
In the decimal system, 10 different digits are used to represent numbers with a base of 10.
However, in the binary system, we have only two digits, 1 and 0. Thus, numbers in the binary
system are represented to the base 2. To avoid confusion, we put a subscript on a number to indicate
its base. For example, 8310 and 472810 are numbers represented in decimal notation or, more
briefly, decimal numbers. The digits 1 and 0 in binary notation have the same meaning as in
decimal notation: 12 = 110 , 02 = 010
To represent larger numbers, as with decimal notation, each digit in a binary number has a value
depending on its position:
102 = (1*21) + (0*20) =210
112 = (1*21) + (1*20) = 310
1002 = (1*22) + (0*21) + (0*20) = 410 and so on.
Again, fractional values are represented with negative powers of the radix:
1001.101 = 23 + 20 + 2-1 + 2-3 = 9.625
In general, for the binary representation of Y = {…d2d1d0.d-1 d-2 d-3…}, the value of
Y is ∑i(bi x2i).
2
Converting Between Binary and Decimal
It is a simple matter to convert a number from binary notation to decimal notation. In fact, several
examples are shown in the above sections. All that is required is to multiply each binary digit by
the appropriate power of 2 and add the results.
To convert from decimal to binary, the integer and fractional parts are handled separately. We convert from
base 10 to base 2 by repeated divisions by 2. The remainders and the final quotient, 1, give us, in order of
increasing significance, the binary digits of N. Figure 2.1 shows an example.
Hexadecimal Notation
Because of the inherent binary nature of digital computer components, all forms of data within
computers are represented by various binary codes. However, no matter how convenient the binary
system is for computers, it is exceedingly cumbersome for human beings. Consequently, most
computer professionals who must spend time working with the actual raw data in the computer
prefer a more compact notation. Figure 2.2 Decimal Notation to Binary Notation for Fractions.
3
What notation to use? One possibility is the decimal notation. This is certainly more compact than
binary notation, but it is awkward because of the tediousness of converting between base 2 and
base 10. Instead, a notation known as hexadecimal has been adopted.
Binary digits are grouped into sets of four. Each possible combination of four binary digits is
given a symbol, as follows:
Because 16 symbols are used, the notation is called hexadecimal, and the 16 symbols are the
hexadecimal digits. A sequence of hexadecimal digits can be thought of as representing an integer
in base 16.
First position (rightmost digit) in a hexadecimal number represents a 0 power of the base (16).
Last position in a hexadecimal number represents x power of the base (16). Example 16x where x
represents the last position - 1
For example: 2C16 = (216*161) + (C16*160)
= (210 * 161) + (1210 * 160) = 44
Hexadecimal notation is used not only for representing integers. It is also used as a concise notation
for representing any sequence of binary digits, whether they represent text, numbers, or some other
type of data. The reasons for using hexadecimal notation are:
1. It is more compact than binary notation.
2. In most computers, binary data occupy some multiple of 4 bits, and hence some multiple
of a single hexadecimal digit.
3. It is extremely easy to convert between binary and hexadecimal.
As an example of the last point, consider the binary string 1101 1110 0001. This is equivalent to
1101 1110 0001 = DE116. This process is performed so naturally that an experienced programmer
can mentally convert visual representations of binary data to their hexadecimal equivalent without
written effort.
4
2.2. Complements
Binary system complements
As the binary system has base r = 2. So the two types of complements for the binary system are
2's complement and 1's complement.
1's complement
The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's. This is
called as taking complement or 1's complement. Example of 1's Complement is as follows.
2's complement
The 2's complement of binary number is obtained by adding 1 to the Least Significant Bit (LSB)
of 1's complement of the number.
2's complement = 1's complement + 1
Example 1: 2’s complement of the following 5 bit number
6
There are 3 types of non-numeric representation methods.
1. ASCII
American Standard Code for Information Interchange (ASCII) is the most widely used
alphanumeric code set. It is used for representing uppercase and lower case English letters (i.e.,
Latin alphabet), numbers and punctuations. There are 128 standard ASCII codes which are
represented using 7-bits (also called as 7-bit ASCII).
2. EBCDIC
Extended Binary Coded Decimal Interchange Code (EBCDIC) is used primarily by large IBM
computers (super computer and main frames). It is not widely used, in contrast to ASCII.
3. Unicode
Although ASCII is heavily used it cannot represent more than 128 characters. However, there are
hundreds of alphabets (character sets) in the world and they have many characters in them. So, it
is not possible to use ASCII to represent characters in a language like Amharic. (Many proprietary
schemes got around this problem, but there is no standard way for this). Therefore, there was a
need for new standard coding system which can support a large number of characters. Unicode is
the solution. Unicode uses 32 bits to overcome the limitation of the number of characters. Unicode
system can represent multiple character sets, including Amharic and others.