Department of Computer Science
CHAPTER 3
Data Representation and Numbering 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.
So data are represented in the form of a code that can have a corresponding electrical signal. Computers are built
from components that have two values; on/off
The binary number system, which has only two digits 0 and 1 is used to express the two states
Internal arithmetic operations of a digital computer are actually performed in binary number system.
3.1 Number System
A number system is a set of symbols used for counting. There are various number systems
Example: Decimal, Binary, octal-decimal, hexadecimal etc.
The Decimal Number System
The Decimal number system is based on the ten different digits (or symbols) 0,1,2,3,4,5,6,7,8,9. We
say it is a base ten number system. Though it is widely used, it is inconvenient for computer to
represent data. So we need another number system.
The Binary number system
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 binary number system is
also possible.
Binary 000 001 010 011 100 101 110 111 1000 1001 1010 1011 1100
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 Etc...
Octal number System (base 8) (Oct)
It uses 8 symbols 0-7 to represent numbers; like binary number system it is complete number system.
Example: 77 in octal equals 49 in decimal and 111111 in binary.
Hexadecimal number system (16) (hex)
It uses 16 symbols to represent numbers. But for the numbers greater than 15 they represented in terms
of the 16 symbols. For example the decimal number 16 represented as 10. These symbols are 0,1,…
9,A,B,C,D,E,F.
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.
3.2 Conversion from one Base to Another
The values that numbers have with a 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, the symbols 5 &4 can represent
either 54 or 45 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 135 is in base 10 number system.
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.
Conversion from decimal (base 10) to other bases (base M)
To convert a decimal number X to a number in base m, divide X by m, store the remainder, again
divide the quotient by M, store the remainder, and continue until the quotient becomes 0. And
concatenate (collect) the remainders starting from the last up to the first.
Conversion from base M (other than base 10) to base 10 (decimal)
1
Department of Computer Science
To convert a number X consists of digits X1 X2 X3 …Xn in base M to decimal; simply expand the
number with base M. That is
(X1X2X3…Xn) m =X1*mn-1+X2*mn-2 +X3*mn-3+...+ Xi*mn-i+… Xn-1m1+Xn*m0 =Y10
The binary number 1101 may be expanded as
(1101)2 =1*23+1*22+0*21+1*20
= (1*8)+(1*4)+(0*2)+(1*1)
= 8+4+0+1
= 1310
Conversion from binary (base2) to Octal (base 8) or hexadecimal (base16) and vice versa
To convert a number in binary to octal group three binary digits together starting from the last digit
(right) and if there are no enough digits add zeros to the front end (left) and find the corresponding
decimal of each group.
Eg. [Link] 1001001 to octal 2. Convert 101101001 to octal
Solution. 1001001=001,001,001 Solution. 101101001 =101,101,001
= 1118 =5518
To convert binary to hexadecimal, follow the same procedure to the above but the group should have
four binary digits..
Eg. [Link] 111100100 to hexadecimal 2. Convert 111001111 to Hexadecimal
Soln. 111100100 =0001 1 Soln. 111001111 =0001 1100 1111
110 0100 = 1 12 15
= 1 14 4 =1 B F
=1 E 4 = (1BF) 16
= 1E416
To convert from Octal to binary, convert each octal digit to its equivalent 3 bit binary starting from
right.
Example: Convert (675) eight to binary
675eight =110 111 101
=110111101two
To convert from Hexadecimal to binary convert each hexadecimal digit to its equivalent 4-bit binary
starting from right.
Example. [Link] 23416 to binary 2. Convert 2AC to binary
Soln. 23416 =0010 0011 0100 solun. 2AC16 =0010 1010 1100
= 10001101002 =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.
Example . 1. Convert 2358 to hexadecimal 2. Convert 1A to Octal
2358=010 011 101 1A= 0001 1010
=0000 1001 1101 = 000 011 010
= 0 9 13 = 0 3 2
=9D16 =328
- Base ‘n’ number has ‘n’ possible digits and the digits are 0 to n-1
Notice: before you start converting a number to a specified base, check whether the given number is
legal one
e.g. (230)2 is illegal and same is true for (98)8
Exercise: Given A= (1011011)2 and B= (011101)2 Find 1. A+B 2. A-B
3.3 Binary Arithmetic?
3.3.1 Binary addition?
3.3.2 Binary subtraction?
2
Department of Computer Science
3.4 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 equivalent arrangements of bits.
There are different coding systems that convert one or more character sets into computer codes. Some
are: EBCDIC, BCD, ASCII-7 & ASCII-8.
Units of Data Representation
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;
These units are based on the binary number system;
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 is 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;
If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where KB stands
for kilobyte.
1 Kilobyte (1KB) is 2 10 or 1024 bytes
1 Megabyte (MB) is 2 20 bytes or 2 10 kilobytes
1 Gigabyte (GB) is 2 30 bytes or 2 20 kilobytes or 2 10 megabytes
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 8-bits, 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.