0% found this document useful (0 votes)
53 views10 pages

Ch-3 Data Representation1

The document discusses different data representation units used in computers like bits, bytes and words. It also explains different number systems like binary, decimal, octal and hexadecimal systems used to represent data and perform arithmetic operations in computers. Methods to convert between these number systems are also provided with examples.

Uploaded by

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

Ch-3 Data Representation1

The document discusses different data representation units used in computers like bits, bytes and words. It also explains different number systems like binary, decimal, octal and hexadecimal systems used to represent data and perform arithmetic operations in computers. Methods to convert between these number systems are also provided with examples.

Uploaded by

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

CHAPTER THREE

Data Representation and Computer Arithmetic


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.

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 of data representation 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.
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 using a single byte is 2 8 or 256 possible
combinations. Each byte can represent a character (a character is 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. If the computer memory is

Compiled By Leyila Dile


524288 byte, this is expressed in short by saying 512KB, where KB stands for
kilobyte.
- 1 Kilobyte (1KB) is 210 or 1024 bytes
- 1 Megabyte (MB) is 220 bytes or 210 kilobytes
- 1 Gigabyte (GB) is 230 bytes or 220 kilobytes or 210 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 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 larger the word length
a computer has the more powerful and faster it is.
Nibble: Group of 4 continuous bits

Concept of Number Systems and Binary Arithmetic


Since the early days of human civilization, people have been using their fingers, sticks,
and other things for counting. As daily activities became more complex, numbers became
more important in trade, time, distance, and in all spheres of human life. A number
system defines a set of values used to represent quantity. Any number is made up of
individual digits. For example the number 803 consists of 3 digits: 8, 0 and 3. The value
of each digit depends on three things:
 The digit itself
 The position of the digit in the number
 The base of the number
There are various number systems – the decimal, binary, octal, hexadecimal, etc each
differs one another by the number of symbols used in the system. Each numbering system
used different symbols to represent a given quantity.
For a computer, everything is a number whether it may be numbers, alphabets,

Compiled By Leyila Dile


punctuation marks, its own instructions, etc. The number systems that are generally used
by computers are: decimal, binary, octal, and hexadecimal.

The Decimal Number System


The primary number system used is a base ten number system or 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).
Starting at the decimal point and moving to the left, each position is represented by the
base (radix) value (10 for decimal) raised to power. The power starts at Zero for the
position just to the left of the decimal point. The power incremented for each positions
that continues to the left. Moving to the right of the decimal point is just like moving to
the left except that we will need to place a minus sign in front of each power.
For example: (8762)10 = (8*103) + (7*102) + (6*101) + (2*100)
(0.475)10= (4*10-1) + (7*10-2) + (5*10-3)
The decimal system is not suited for representation of numbers in a computer because the
computer is composed of switches that have only two states; on and off whereas the
decimal system requires ten symbols or states. Hence the most suitable number system is
the binary number system, which has two symbols ‘0’ and ‘1’, called bits.

The Binary number system

Computers do not use the ten digits of the decimal system for counting and arithmetic.
Their internal structure (mainly the CPU and memory) are made up of millions of tiny
switches that can be either in an ON or OF states. Two digits, 0 and 1, are used to refer
for these two states.
Binary number system is based on the two different digits; 0 and 1. With binary number
system, it is very easier for the hardware to represent the data. Binary number system is
base two number system.
For example: (01100)2 , (10110.011)2 , etc
110 can be expanded as 1 X 22 + 1 X 21 + 0 X 20 and thus this has a decimal value 4 + 2 +
0=6

Compiled By Leyila Dile


11 .110 can be written as 1 X 21 + 1 X 20 + 1 X 2-1 + 1 X 2-2 + 0 X 2-3 and the decimal
value is 2 + 1 + 1/2 + 1/4 + 0 = 3.75

Octal number system


The octal number system with its eight symbols (0, 1, 2, 3, 4, 5, 6, 7) is a base 8 system.

For example: (322)8, (10.25)8, etc


In this number system the digits represent co-efficient of powers of 8.

For example, 703 can be expanded as 7 X 8 2 + 0 X 81 + 3 X 80 and the decimal value is


448 + 0 + 3 = 451.

Hexadecimal number system


Hexadecimal number system is another number system that works exactly like the
decimal and binary number systems, except that the base is 16. It uses 16 symbols (0-9,
and A-F characters to represent 10-15).
For example: (8F0)16 , (D.45)16, etc
Here the digits represent co-efficient of powers of 16.
For eg., 1AB can be represented as
1 X 162 + A X 161 + B X 160 = 1 X 162 + 10 X 161 + 11 X 160 = 256 + 160 + 11 = 427

Conversion between Number Systems


Computers use binary numbers for internal data representation whereas they use decimal
numbers externally. Therefore, there should be some conversion between number
systems in order to represent data in a computer that is originally represented in other
number systems. Some conversion methods are discussed below.
Decimal to Binary
It is important to note that every decimal number system has its equivalent binary
number. For example
Binary Decimal Binary Decimal
0 0 101 5
01 1 110 6
10 2 111 7
11 3 1000 8
100 4 1001 9 etc.

Compiled By Leyila Dile


Conversion from binary to its equivalent decimal and from decimal to its equivalent
binary is possible. The method, which is used for the conversion of decimal into binary,
is often called as the remainder method. This method involves the following steps.
- Begin by dividing the decimal number by 2 (the base of binary number
system)
- Note the remainder separately as the rightmost digit of the binary equivalent
- Continually repeat the process of dividing by 2 until quotient is zero and keep
writing the remainders after each step of division (these remainders will either
be 0 or 1)
- Finally, when no more division can occur, write down the remainders in
reverse order (last remainder written first)
Example: 1. Convert decimal 25 to its binary equivalent

Remainder
2 25
2 12 1
2 6 0 The Binary equivalent of 25(10) is 11001(2)
2 3 0
1 1

3. Determine the binary equivalent of (44)10 (solution: 1011002)


Taking the remainder in reverse order we have 101100. Thus the binary equivalent of
(44)10 is (101100)2
In general 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 is 0. And concatenate (collect) the remainders starting from the last up to the
first.
Example: Convert decimal 314 to its octal equivalent

8 314
8 39 2 The octal equivalent of 314(10) is 472(8)
8 4 7
8 0 4

Convert 7810 to base eight (Octal)


7810=1168

Compiled By Leyila Dile


Example: Convert the Decimal 5280 into its Hexadecimal equivalent

16 5280
16 330 0 The Hexadecimal representation of
16 20 A (10) 5280(10) is 14A0 (16)
1 4

Convert 3010 to base sixteen (hexadecimal)


3010=1E16
Binary to Decimal
In the binary to decimal conversion, each digit of the binary number is multiplied by its
weighted position, and each of the weighted values is added together to get the decimal
number.
Example: Determine the decimal equivalent of (100100)2
1*25 + 0*24 + 0*23 + 1*22 + 0*21 +0*20 = 32+4 =36
Therefore, the decimal equivalent of (100100)2 is 36
In general To convert a number X consists of digits X 1 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
Example: convert (234)8 to decimal
=2*82 + 3*81 + 4*80 = 128+24+4 = 156
Example: convert (A1B) 16 to decimal
=A*162 + 1*161 + B*160 = 2587
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 Octal of each group.
Example: Convert 1001001 to octal Convert 101101001 to octal
1001001=001,001,001 101101001 =101,101,001
= 1118 =5518
Convert 110010(2) to octal
110010(2) = 110 010 (2) = 62(8)

Compiled By Leyila Dile


To convert binary to hexadecimal group four binary digits together starting from right
and if there are no enough digits add zeros at the left.
Example: Convert 111100100 to Convert 111001111 to Hexadecimal
hexadecimal 111001111 =0001 1100 1111
111100100 =0001 1110 0100 =1 12 15
=1 14 4 =1 C F
=1 E 4 =(1CF)16
= (1E4)16
Convert 110010(2) to hexadecimal
110010(2) = 0011 0010(2) = 32 (16)
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 Convert 231eight to binary

675eight =110 111 101 231eight = 010 011 001

=(110111101)two =(10011001)two

To convert from Hexadecimal to binary convert each hex. Digit to its equivalent 4-bit
binary starting from right.
Example: Convert 23416 to binary Convert 2AC to binary
23416 =0010 0011 0100 2AC16 =0010 1010 1100
= 10001101002 =10101011002
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: Convert 2358 to hexadecimal Convert (1A)16 to Octal
2388=010 011 101 1A=0001 1010
=0000 1001 1101 =000 011 010
=0 9 13 = 0 3 2
=9D16 =328

Compiled By Leyila Dile


Summary of conversion from One base to another base
From base To base Method
2 10 Expand binary number in powers of 2
10 2 Factor the decimal number by 2
2 8 Group 3 binary digits together
8 2 Each Octal digit is converted to 3 binary digits
2 16 Group 4 binary digits together
16 2 Each hexadecimal digit is converted to 4 binary digits
8 10 Expand the number in powers of 8
10 8 Factor the decimal number by 8
16 10 Expand the number in powers of 16
10 16 Factor the decimal number by 16
8 16 Go from 8 …….2…….16
16 8 Go from 16 …….2…….8

Converting decimal numbers with fractions to Binary.


 First change the integer part to its equivalent binary.
 Multiply the fractional part by 2 and take out the integer value, and again multiply the
fractional part of the result by 2 and take out the integer part, continue this until the
product is 0.
 Collect the integer values from top to bottom & concatenate with the integer part.
Ex. A) Convert the Decimal 0.25 to its Equivalent Binary

.25
X 2
0 .50 The Binary equivalent of .25(10) is .01(2)
X 2
1 .00

B) Convert 12.2510 to binary 1100.01


C) Convert 3.1875 to binary 11.0011

Compiled By Leyila Dile


Converting Binary with fraction to decimal.
To convert a binary number Y1Y2Y3Y4Yn.d1d2d3..dm to decimal first convert the integer
part to decimal by using
y1 y2 y3 y4…yn=y1*2n-1+y2*2n-2+….yj*2n-j+….+yn-1*21+yn*20=Q and convert the fractional
part to decimal by using
d1d2d3…dm=d1*2-1+d2*2-2+d3*2-3+…+dj*2-j+..+dm*2-m=R
then decimal equivalence of y1 y2 y3 y4…..yn.d1d2…dm will be Q+R where Q is the
integer part and R is the fractional part.

Ex1 : Convert 11001.0101 to decimal Ex 2: Convert 1000.1 to decimal


11001 = 1x24 + 1x23 1000 = 1+23 +0+0+0=8
+0x22+0x21+1x20= 16+8+1= 25= Q 1= 1x2-1=½ = 0.5
0101 =0x2-1+1x2-2+0x2-3+1x2-4 1000.1 = 8.510
= 0+¼+0+1/16 = 0.3125 = R
=>11001.0101 = 25.3125.

Conversion from Binary with fraction to Octal/hexadecimal

 Group three/four digits together starting from the last digit of the integer part, and if
there is less number of digits add some zeros in the beginning.
 Group three/ four digits together starting from the first digit of the fractional part, and
if there is less number of digits add some zeros to the end.
 Covert each group of the integer and the fractional part to their equivalent
Octal/hexadecimal and collect the results by adding point (.) to separate the integer part
from the fractional part.

Ex1:- 1010.10101(2) = 001 010. 101 010(2) = 1 2. 5 2(8)

= 1010. 1010 1000(2) = A. A 8(16)

Ex 2:- Covert 1010.01112 to octal


Ex3:- Covert 1110101.101112 to hexadecimal

Compiled By Leyila Dile


Conversion from Octal or hexadecimal with fraction to binary.
 Convert each Octal/hexadecimal digit to its equivalent 3/4-bit binary digit.
 Collect the binary sequences by separating the integer part binaries from the
fractional part binaries with point (.)

Conversion from Octal with fraction to hexadecimal


 To convert from Octal to hexadecimal, first convert the Octal to binary and then the
binary to hexadecimal
Conversion from Hexadecimal with fraction to octal
 To convert from hexadecimal to Octal, first convert the hexadecimal to binary and
then the binary to Octal.
Conversion from octal/hexadecimal with fraction to decimal.

 To convert from Octal/hexadecimal to decimal, first convert to binary and –then the
binary to decimal.

Compiled By Leyila Dile

You might also like