Chapter 4
Chapter 4
Chapter Four
Data Representation in Computers
Objectives:
To understand how data represented, flow, stored and processed inside the computer.
To understand different number systems.
To understand how to convert from one base to another and apply arithmetic operators on binary
number system.
We enter data into a computer or review (see) output data from a computer using the letter of alphabet, various
special symbols, and the numerals in the decimal number system. But since computer is an electronic device
which understands electrical flow (signal) there is no letter, symbol or number inside the computer. Computer
works with binary numbers. As a semiconductor is conducting or isn’t conducting; a switch is closed or opened. It
is not surprising, therefore, that almost all of the present day computers are based on binary system of
representation that uses only two symbols – 1 and 0.
Any information stored in the computer system is first converted into binary number and then stored in the
computer memory or hard disk in the form of 1s and 0s.
Number Remainder
7/2
2 7
2 3 1
1 1
When data is stored, processed or communicated within the computer system, it is packed in units;
Arranged from the smallest to the largest, the units are called bit, byte and word;
BIT
Bits are the smallest units and can convey only two possible states 0 or 1; bit stands for binary digits;
A bit is a single element in the computer, on a disk that stands for either “ON” indicating 1 or “OFF”
indicating 0;
In the computer “ON” is represented by the existence of current and “OFF” is represented by the non-
existence of current.
On a magnetic disk, the same information is stored by changing the polarity or magnetized particles on
the disk’s surface.
BYTE
Bits can be organized into large units to make them represent more and meaningful information. This
large unit is called a byte and is the basic “unit of data representation” in a computer system.
The commonly used byte contains 8 bits. Since each bit has two states and there are 8 bits in a byte, the
total amount of data that can be represented is 28 or 256 possible combinations.
Each byte can represent a character (a character could be either a letter, a number or a special symbol such as
+,-,?,*, $, etc.
A byte is then used as a unit of measurement in the computer memory, processing unit, external storage and
during communication.
e.g. If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where KB stands for
kilobyte.
1 Byte is 8 bites
1 Kilobyte (1KB) is 210 or 1024 bytes
1 Megabyte (MB) is 220 bytes or 210 kilobytes= 1024KB.
1 Gigabyte (GB) is 230 bytes or 220 kilobytes or 210 megabytes =1024MB.
WORD
Word refers the number of bits that a computer process at a time or a transmission media transmits at a
time. Although bytes can store or transmit information, the process can even be faster if more than one
byte is processed at a once; A combination of bytes, then form a “word”.
A word can contain one, two, three or four bytes based on the capacity of the computer. Word length is
usually given in bits
We say that a computer is an 8-bit, a 16 bit, a 32 bit or a 64 bit computer to indicate that the amount of
data it can process at a time.
The large the word length a computer has the more powerful and faster it is.
Coding Methods
It is possible to represent any of the character in our language in a way as a series of electrical switches in
arranged manner.
These switch arrangements can therefore be coded as a series of an equivalent arrangements of bits.
There are different coding systems that convert one or more character sets into computer codes, some are:
-BCD (Binary Coded Decimal), ASCII (American Standard Code for Information Interchange),and
Unicode are the most popular text coding systems invented.
Though it is widely used, it is inconvenient for computer to represent data. So we need another number system.
Binary number system (base 2)
Binary number system is based on the two different digits; 0 and 1. It is important to note that every
decimal number system has its equivalent binary number.
Conversion from binary to its equivalent decimal and from decimal to its equivalent binary is possible;
Operation on bina4ry number system is also possible.
The most elementary form to organize data within a computer (an electronic device) is in the form of a
code which utilizes the “ON” and “OFF” states of electric switches or there is “current” and “no current”
condition of the electronic components.
We see that the nature of the electronic devices has similarity with the binary number system in that both
represent only two elementary states.
It is therefore convenient to use binary number system to represent data in a computer. An “ON”
corresponds to a 1; an “OFF” corresponds to a 0.
In the computer “ON” is represented by the existence of a current and “OFF” is represented by non-
existence of current
On a magnetic disk, the same information is stored by changing the polarity of magnetized particles on the disk’s
surface
Octal number System (base 8) (Oct)
Again what would happened if we had only 8 fingers off course we would have used the 8 symbols (0-7)
and for numbers greater than we would represented them in terms of the first 8 symbols example for 8,10
and so on.It uses 8 symbols 0-7 to represent numbers
When we compare the octal with the decimal 0-7 in octal is the same as 0-7 in decimal but 10 in octal is
not the same as 10 in decimal because 10 in octal holds the position of 8 in decimal, off course 10 in octal
is the same as 8 in decimal.
Hexadecimal number system (16) (hex)
Suppose we had 16 fingers instead of 10 in case of 10 fingers they invented new symbols until they
exhausted all their fingers. Now they would have to invent new symbols because there would have been
some more fingers left unrepresented. These extra symbols are usually represented by the letters at the
beginning of the English alphabet.
It uses 16 symbols to represent numbers. But for the numbers greater than 15 they represented in terms
of the 16 symbols example 16 as 10 and so on.
When we compare the hexadecimal with decimal 0-9 in hexadecimal is the same as 0-9 in decimal but 10
in hexadecimal is not the same as 10 in decimal, off course 10 in hexadecimal is equal to 16 in decimal
because it holds the position of 16 in decimal.
Conversion from one Base to Another
The values that members have within given number systems are largely determined by their positional notation.
Positional notation means that the position of one symbol relative to other symbols in a given number system
determines the value of that symbol. For example, these symbols 1 & 7 can represent either 17 or 71 depending
upon their relative position to one another.
The decimal number 135 may be expanded as:
(135) 10 = 1*102+3*101+5*100
The subscript 10 is used to indicate that 135 is a base 10 number. The number 10 in binary is not the same
as 10 in decimal because the value of 1 in the binary is not the same as the value of the 1 in the decimal.
The binary number 1101 can be expanded as
11012 = 1*23+1*22+0*21+1*20
=1 14 4
= 1E416
To convert from Octal to binary, convert each octal digit to its equivalent 3 bit binary starting from right.
Example: Convert (675)8 to binary
6758 =110, 111, 101
=1101111012
Convert 2318 to binary
2318 = 010, 011, 001
=100110012
To convert from Hexadecimal to binary convert each hex digit to its equivalent 4-bit binary, starting from
right.
Example: Convert 23416 to binary
23416 =0010, 0011, 0100
= 10001101002
Convert 2AC to binary
2AC16 =0010, 1010, 1100
=10101011002
Conversion from Octal to hexadecimal and vice versa
To convert from Octal to hexadecimal, first we have to convert to binary and the binary to hexadecimal.
To convert from hexadecimal to Octal, first we have to convert to binary and then the binary to Octal.
EX.1. Convert 2358 to hexadecimal
2358=010, 011, 101
=010011101
=0000, 1001, 1101
=0 9 13
=9D16
Convert 1A to Octal
1A=0001, 1010
=00011010
=000, 011, 010
=0 3 2
=328
Coding Examples:
Character zone (4 bits) digit (4 bits)
0-9 3 0-9
A-O 4 1-15
P-Z 5 0-10
a-o 6 1-15
p-z 7 0-10
a 0110 0001
b 0110 0010
A 0100 0001
B 0100 0010
? 0011 1111
+ 0010 1011
1 0011 0001
complementing every bit in the original representation. Each 0 is transformed into a1 and each 1 into a0.
In our example, the one’s complement representation of -3 is 11111111.
Ex: +2 is 00000010
-2 is 11111101
3. Two’s Complement Representation
In two’s complement representation, positive numbers are represented, as usual, in singed binary, just like
in one’s complement. The difference lies in the representation of negative numbers. A negative number
represented in two’s complement is obtained by first computing the one’s complement and then adding
one.
Ex: +3 is represented in signed binary as 00000011
Its one’s complement representation is 11111100.
Reading assignment
Convert the following fraction numbers to each base
A,(123.75)10 to base 2, 8, 16
B, (abcd.25) to base 2, 8, 10
C (67.24)8 to bae 2 , 10, 16
D, (10101011011.10101101)2 to base 8, 10, 16