0% found this document useful (0 votes)
5 views7 pages

Numerical Analysis Chapter 2

Chapter 2 discusses the representation of data in computers, focusing on number systems such as binary, decimal, and hexadecimal, as well as data types and memory capacity. It explains the conversion between these systems, complements in binary, and fixed- and floating-point representations. Additionally, it covers non-numeric data representation methods, including ASCII, EBCDIC, and Unicode.

Uploaded by

chaladinsa425
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Numerical Analysis Chapter 2

Chapter 2 discusses the representation of data in computers, focusing on number systems such as binary, decimal, and hexadecimal, as well as data types and memory capacity. It explains the conversion between these systems, complements in binary, and fixed- and floating-point representations. Additionally, it covers non-numeric data representation methods, including ASCII, EBCDIC, and Unicode.

Uploaded by

chaladinsa425
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Chapter 2

Number system and codes


The main concern of this chapter is the way data can be represented in the computer. Data is raw
facts, figures, symbols, notations that represent the ideal and/ or physical reality. Furthermore, data
can be measured in the following units:
i. Bit, represents binary digit, includes either 1 or 0. It is the smallest unit of data.
ii. Byte, sequence of 8 bits, includes 00000000, 00000001, up to 11111111.
iii. Word = a sequence of N bits where N = 16, 32, 64 depending on the computer.
Measuring Amount of Data/Memory Capacity
1 kilobyte = 1 KB = 210 bytes = 1024 bytes (appx 103 bytes)
1 Megabyte = 1 MB = 220 bytes = 1,048,576 bytes (appx 106 bytes)
1 Gigabyte = 1 GB = 230 bytes = 1,073,741,824 bytes (appx 109 bytes)
We can represent Boolean truth values in a virtual computer using bits: 1 = true, 0 = false.
2.1. Data types
Machine instructions operate on data. In computer system, the most important general categories
of data are:
• Addresses • Characters
• Numbers • Logical data
Representation of Numeric Data
Number is a general name that represents digits. In digital world, numbers can be operated in
different systems, namely, binary, octal, decimal and hexadecimal numbers systems. A digital
system can understand positional number system only where there are only a few symbols called
digits and these symbols represent different values depending on the position they occupy in the
number.
A value of each digit in a number can be determined using:
 The digit
 The position of the digit in the number
 The base of the number system (where base is defined as the total number of digits available
in the number system).
A. Decimal Number System
In everyday life we use a system based on decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to represent
numbers and refer to the system as the decimal system. Consider what the number 83 means. It
means eight tens plus three: 83 = (8 * 10) +3

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

Example 2. 2’s complement of the following 8 bit number


00101001
11010110 First, invert the bits
+ 00000001 then, add 1
= 11010111
The 2’s complement of 00101001 is 11010111
Example 3. 2’s complement of the following 8 bit number
00011100
11100011 After, invert the bits. 0 becomes 1, 1 becomes 0.
+ 00000001 then, we add 1.

11100100 Results 2’s Complement.


5
2.3. Fixed- and floating-point representation
As the name implies, floating point numbers are numbers that contain floating decimal points. For
example, the numbers 5.5, 0.001, and -2,345.6789 are floating point numbers. Numbers that do
not have decimal places are called integers. Computers recognize real numbers that contain
fractions as floating-point numbers. When a calculation includes a floating point number, it is
called a "floating point calculation."
A real number (that is, a number that can contain a fractional part). The following are floating-
point numbers:
1.0 or -111.5 or ½ or 3E-5
The last example is a computer shorthand for scientific notation. It means 3*10-5 (or 10 to the
negative 5th power multiplied by 3).
2.4. Codes
Codes are used to represent non-numeric data. A non-numerical data is form of data which cannot
be expressed in numerical values. Usually, this data is calculated in word form like a, b, c, d etc.
This type of data can only be identified in word format.
The computer internally has only two “characters”: 0 and 1. So the question is: how can we
represent our characters listed above using 0 and 1? Note that in this context, there is no numerical
value associated with any character; each is simply a symbol. A simple solution is to assign a
unique pattern (code) of 0s and 1s for each of our characters (i.e., encode each using 0 and 1).
Since there are many possible ways of doing this, we need a standard so that every computer can
use the same encoding to enable sharing of data among computers.
Example:
Obviously, numbers are represented in bits. For example: 00000000 = 0, 00000001 = 1, 00000010
= 2, 00000011 = 3. Text also can be represented by these same numbers. When text represented
by numbers, every letter and character are represented by a single number.
So, for example if you wanted to store "hello": h = 104, e = 101, l = 108, l = 108, o= 111.
So, it would be stored as 104 101 108 108 111.

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.

You might also like