0% found this document useful (0 votes)
25 views25 pages

Lec9!10!11 Data Representation

The document provides an overview of data representation in computers, explaining the differences between analog, digital, and hybrid computers, and the importance of binary representation. It details various number systems including decimal, binary, octal, and hexadecimal, and discusses how data is represented in electronic circuits, magnetic media, and optical devices. Additionally, it covers the concepts of bits, bytes, and conversions between different number systems.

Uploaded by

m7546919
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)
25 views25 pages

Lec9!10!11 Data Representation

The document provides an overview of data representation in computers, explaining the differences between analog, digital, and hybrid computers, and the importance of binary representation. It details various number systems including decimal, binary, octal, and hexadecimal, and discusses how data is represented in electronic circuits, magnetic media, and optical devices. Additionally, it covers the concepts of bits, bytes, and conversions between different number systems.

Uploaded by

m7546919
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/ 25

7

Data Representation
(Machine level -
representation-number
system)
DATA REPRESENTATION IN A COMPUTER
1. Introduction
• Computers are classified according to functionality, physical size
and
purpose.
• Functionality, Computers could be analog, digital or hybrid.
Digital computers process data that is in discrete form whereas
analog computers process data that is continuous in nature.
Hybrid computers on the other hand can process data that is
both discrete and continuous.
• In digital computers, the user input is first converted and
transmitted as electrical pulses that can be represented by two
unique states ON and OFF. The ON state may be represented by
a “1” and the off state by a “0”.The sequence of ON’S and OFF’S
forms the electrical signals that the computer can understand.
• A digital signal rises suddenly to a peak voltage of +1 for some time
then
suddenly drops -1 level on the other hand an analog signal rises
to +1 and then drops to -1 in a continuous version.

2. concepts of data representation


in digital computers
Data and instructions cannot be entered and processed directly into
computers using human language. Any type of data be it numbers, letters,
special symbols, sound or pictures must first be converted into machine-
readable form i.e. binary form.
Due to this reason, it is important to understand how a computer
together with its peripheral devices handles data in its electronic
circuits, on magnetic media and in optical devices.

Data representation in digital circuits

• Electronic components, such as microprocessor, are made up of


millions of electronic circuits. The availability of high voltage(on) in
these circuits is interpreted as ‘1’ while a low voltage (off) is
interpreted as ‘0’.This concept can be compared to switching on and
off an electric circuit. When the switch is closed the high voltage in
the circuit causes the bulb to light (‘1’ state).on the
1
other hand when the switch is open, the bulb goes off (‘0’ state).
This forms a basis for describing data
representation in digital computers using the binary number system.

Data representation on magnetic media

• The laser beam reflected from the land is interpreted, as 1.The laser
entering the pot is not reflected. This is interpreted as 0.The
reflected pattern of light from the rotating disk falls on a receiving
photoelectric detector that transforms the patterns into digital form.
The presence of a magnetic field in one direction on magnetic media
is interpreted as 1; while the field in the opposite direction is
interpreted as “0”.Magnetic technology is mostly used on storage
devices that are coated with special magnetic materials such as iron
oxide. Data is written on the media by arranging the magnetic
dipoles of some iron oxide particles to face in the same direction
and some others in the opposite direction

Data representation on optical media

In optical devices, the presence of light is interpreted as ‘1’ while its


absence is interpreted as ‘0’.Optical devices use this technology to
read or store data. Take example of a CD-ROM, if the shiny surface is
placed under a powerful microscope, the surface is observed to have
very tiny holes called pits. The areas that do not have pits
are called land.

Reason for use of binary system in


computers
• It has proved difficult to develop devices that can understand
natural language
directly due to the complexity of natural languages. However, it is
easier to construct electric circuits based on the binary or ON and
OFF logic. All forms of data can be represented in binary system
format. Other reasons for the use of binary are that digital devices
are more reliable, small and use less energy as compared to analog
devices.

2
Bits, bytes, nibble and word
• The terms bits, bytes, nibble and word are used widely in
reference to computer memory and data size.

• Bits: can be defined as either a binary, which can be 0, or 1.It is


the basic unit of data or information in digital computers.

• Byte: a group of bits (8 bits) used to represent a character. A byte


is considered as the basic unit of measuring memory size in
computer.
• A nibble: is half a byte, which is usually a grouping of 4 bits.
One nibble is equal to 0.5 byte.

• Word: two or more bits make a word. The term word length is
used as the measure of the number of bits in each word. For
example, a word can have a length of 16 bits, 32 bits, 64 bits etc.

Types of data representation


• Computers not only process numbers, letters and special
symbols but also complex
types of data such as sound and pictures. However, these complex
types of data take a lot of memory and processor time when
coded in binary form.
• This limitation necessitates the need to develop better ways of
handling long streams of binary digits.
• Higher number systems are used in computing to reduce these
streams of binary digits into manageable form. This helps to
improve the processing speed and optimize memory usage.

Number systems and their


representation
• A number system is a set of symbols used to
represent values derived from a common base or
radix.
• As far as computers are concerned, number systems can be
classified into two major categories:
• decimal number system
3
• binary number system
• octal number system
• hexadecimal number system

Decimal number system


• The term decimal is derived from a Latin prefix deci, which
means ten. Decimal number system has ten digits ranging
from 0-9. Because this system has ten digits; it is also called
a base ten number system or denary number system.
• A decimal number should always be written with a subscript 10
e.g. X10
• But since this is the most widely used number system in
the world, the subscript is usually understood and ignored
in written work. However
,when many number systems are considered together, the
subscript must always be put so as to differentiate the
number systems.
• The magnitude of a number can be considered using these
parameters.
• Absolute value
• Place value or positional value
• Base value

▪ The absolute value is the magnitude of a digit in a


number. for example the digit 5 in 7458 has an
absolute value of 5 according to its value in the
number line.
▪ The place value of a digit in a number refers to the
position of the digit in that number i.e. whether; tens,
hundreds, thousands etc.
▪ The total value of a number is the sum of the
place value of each digit making the number.
▪ The base value of a number also k known as the
radix, depends on the type of the number systems that
is being used .The value of any number depends on the
radix. for example the number 10010 is not equivalent to

4
1002.

5
Binary number system
It uses two digits namely, 1 and 0 to represent numbers. unlike in
decimal numbers where the place value goes up in factors of ten, in
binary system, the place values increase by the factor of 2.binary
numbers are written as X2.consider a binary number

such as 10112.The right most digit has a place value of 1×20 while
the left most has a place value of 1×23.

Octal number system


Consists of eight digits ranging from 0-7.the place value of octal
numbers goes up in factors of eight from right to left.

Hexadecimal number system


This is a base 16 number system that consists of sixteen digits ranging
from 0-9 and letters A-F where A is equivalent to 10,B to 11 up to F
which is equivalent to 15 in base ten system. The place value of
hexadecimal numbers goes up in factors of sixteen.

• A hexadecimal number can be denoted using 16 as a subscript or


capital letter H
to the right of the number .For example, 94B can be written as
94B16 or 94BH.

NUMBER SYSTEMS AND CONVERSIONS


FROM ONE SYSTEM TO ANOTHER
1. Number System
• A set of values used to represent different quantities is known
as number system.

6
• For example, a number system can be used to represent the
number of students in a class.

• Digital computer represents all kind of data and information in binary


numbers

• i.e. text, numbers, audio , graphics etc

• Total number of digits used in a number system is called its base or


radix.

• Base is written after the number as a subscript such as 51210

• Important number systems are as follows

1. Decimal number system

2. Binary number system

3. Octal number system

4. Hexadecimal number system

1.1. Binary Number System


• Digital computer represents all kind of data and information in the binary
system

• Binary number system consists of two digits 0 and 1

• 0 is used for off(absent bit) and 1 is used for on (present bits)

• Its base is 2

7
• Combination of binary numbers used to represent different quantities
like 1001

• Important terms used in the binary number system are


❖ Bit: Smallest possible unit of data. Bit is either 0 or 1

❖ Nibble: group of 4 bits.


❖ Byte: group of 8 bits. Nibble is the half byte. 0-3 are called
low-order nibble, and bits 4-7 form the high order nibble
❖ Word: group of two bytes. 0-7 form low-order byte and 8-15 form
high-

order byte. Today’s computer redefine word as a group of four

bytes(32 bits) 2n number of digits can be represented by using n


number of bits i.e. by using 2

bits we can represent 22 = 4 values. Namely 00 , 01, 10 , 11

Term Size(bit Example


s)
1 0
Bit
4 101
Nibbl 0
e
8 0101 1100
Byte
16 0101 1100 0101
Word 1100

1.2. Decimal Number System


• Most commonly used number system

• Also called as natural number system

8
• Consists of 10 digits from 0 to 9

• Base of decimal number system is 10


• The rightmost digit of a number has the lowest weight. This
digits is called Least

Significant Digit (LSD)

• The leftmost digit of a number has the highest weight. This digits is

called Most Significant Digit (MSD)

• The digit 7 in the number 724 is most significant digit


and 4 is the least significant digit

1.3. Octal Number System


• It contains 8 bits

• Starting form 0----7

• So, base of octal numbers is 8

1.4. Hexadecimal number system


• It contains 16 digits
• These are starting from “0” and ends on 15
• The number 10, 11, 12, 13, 14, 15 are represented by A, B, C, D, E, F
respectively. That’s why base of hexadecimal number is
16
• It is required in assembly language programming

9
2. CONVERSION
There are about 12 conversions because we can convert each
number system in other number system.

1.--------------------------- Decimal Binary

2. Decimal--------------Octal

3. Decimal--------------Hexadecimal

4. Binary----------------Decimal

5. Binary Octal

6. Binary----------------Hexadecimal

7. Octal-------------------Decimal

8. Octal Binary

9. Octal-------------------Hexadecimal

10. Hexadecimal-------Decimal

11. Hexadecimal-------Binary

12. Hexadecimal-------Octal

2.1.Conversion of decimal integer to


other number system
• Divide decimal integer by the base of the number
system in which the number is to be converted
• Write down the remainder in reverse order to get the required number

EXAMPLES

1
1.DECIMAL TO
BINARY 1. (88)10
(?)2

2 88

2 44 - 0

2 22 - 0

2 11 - 0

2 5 -1

2 2 -1

2 1 -0

0 -1

(1011000)2

OR

1
2 88

2 44 - 0

2 22 - 0

2 11 - 0

5 -1

2 2 -1

1 -0

(1011000)2

1
2.DECIMAL TO OCTAL

1.(119)10----- (?)8

8 119

8 14 - 7

8 1-6
8 0-1

(0167)8

2. (146)10 ---------- (?)8

8146
818 - 2

8 2-2

0-2

(0222)8

3.Decimal to Hexadecimal
1. (185)10-------------(?)16
16185
1611 - 9

160 - 11

(B9)16
2.1.1. Converting Fractional Decimal
Number to Octal Number
 Multiply the fraction part of decimal number with the
base of the system in which fraction is to be converted.
 The result may have two parts i.e. integer part and fraction
part.
 Multiply the resulting fraction with the base again.
 Repeat minimum 5 steps.
 The integral part is written as answer, from top to bottom.

EXAMPLE
S
1.(0.3)10-----------------()8

Steps Result Fractional Part Integral part


0.3 * 8 2.4 .4 2
0.4 * 8 3.2 .2 3
0.2 * 8 1.6 .6 1
0.6 * 8 4.8 .8 4
0.8 * 8 6.4 .4 6

(0.23146)8

(240.36)10 --------------- (?)8


8240

830 - 0

83 - 6

8 0-3
(0360)8
1
Steps Result Fractional Integral part
Part
.36 * 8 2.88 .88 2
.88 * 8 7.04 .04 7
0.4 * 8 0.32 .32 0
0.32 * 8 2.56 .56 2
0.56 * 8 4.48 .48 4
0.48 * 8 3.84 .84 3

(270243)8
(240.36)10 = (0360.270243)8

2.1.2. Converting Fractional Decimal


Number to Binary Number
DECIMAL TO BINARY
EXAMPLES
1. (375.23)10---(?)2
2 375
2 187 –
1
2 93 – 1
2 46 – 1
2 23 – 0
2 11 – 1

1
2 5–1

1
2 2-1
2 1–0
2 0-1
(01011101
11)2

Steps Result Fractional Integral Part


Part
.23 * 2 0.46 .46 0
.46 * 2 0.92 .92 0
.92 * 2 1.84 .84 1
.84 * 2 4.68 .68 1
.68 * 2 1.36 .36 1
.36 * 2 0.72 .72 0
(001110)2
(0101110111.001110)2

2. (0.56)10 ----------- (?)2

Steps Result Fractional Part Integral Part

0.56 * 2 1.12 .12 1

.12 * 2 0.24 .24 0

.24 * 2 0.48 .48 0

.48 * 2 0.96 .96 0

.96 * 2 1.92 .92 1

.92 * 2 1.84 .84 1

1
(100011)2

2.1.3. Converting Fractional Decimal


Number to Hexadecimal Number
EXAMPL
ES 1.(0.3)10-----(?)16

Steps Result Fraction Integral


al Part Part
0.3 * 16 4.8 .8 4
.8 * 16 12.8 .8 12 = C
.8 * 16 12.8 .8 12 =C

(.4CC)16

Conversion of Binary number to other


number system
1. Binary to Decimal
 Multiply each binary number by 20, 21, 22,….., 2n
 Start multiplying from right side
 Now convert the required number

EXAMPL
ES 1. (11001)2--(?)10
11001= 1*24+1*23+0*22+0*21+1*20
= 16 + 8 + 1

1
= 25
= (25)10

Converting Decimal (Integral &


Fractional part) To Other Number
System
 Multiply each binary number by 2-1, 2-2, 2-3,….., 2-n
 Start multiplying from left side
 Now convert the required number

EXAMPLE
1.(101. 111)2
1* 22+ 0*21+1*20+1*2-1+1*2-2+1*2-3

= 4 + 0+ 1+1/2+1/4+1/8

= 5 + .875
= (5.875)10

Table for 3 bits & 4


bits
8 4 2 1 Number
0 0 0 0 0

0 0 0 1 1

0 0 1 0 2
1
0 1 1 1 3

0 1 0 0 4

0 1 0 1 5

0 0 1 0 6

0 0 1 1 7

1 0 0 0 8

1 1 0 1 9

1 1 1 0 10 = A

1 1 1 1 11 = B

1 0 0 0 12 = C

1 0 0 1 13 = D

1 0 1 0 14 = E

1 1 1 1 15 = F

2.2.2. Binary to Octal


 Take the given number
 Make combination/groups of 3 bits
 If we have number of bits less than 3 in a group then we
add extra bits to left side to make group of three
 Start making groups from right side
 For fractional part starting from left most side
 If we have number of bits less than 3 in a group then we
add extra bits to right side to make group of three
 Change in the octal number

EXAMPL
ES 1.(100101110)2
---------------------------
(?)8
1
2
From table we write the values against each number.

100 101 110

4 5 6 (from

table) (456)8

2. (1001.01110)2 = (?)8
001 001 . 011 100

1 1 . 3 4

2.2.3. Binary to Hexadecimal


 Take the given number
 Make combination/groups of 4 bits
 If we have number of bits less than 4 in a group then we
add extra bits to left side to make group of four
 Start making groups from right side
 For fractional part starting from left most side
 If we have number of bits less than 4 in a group then we
add extra bits to right side to make group of four
 Change in the hexadecimal number

EXAMPLES
1. (0010110001101011)2 = (?)16

2
0010 1100 0110 1011

2 C 6 B (from table)
(2C6B)16

2.3. Octal to Binary


 Take octal number
 Write equivalent code for each digit in bit (3 bits)
 Combine all bits
 We get the required results

EXAMPLES
1. (456)8 = (?)2
4 5 6
100 101 110 (from table)

(456)8 = (100101110)2

2.4. Hexadecimal to Binary


 Take number
 Write binary code for each number (4 bits)
 It is the result

EXAMPL
ES 1.(2C6B)16 =
(?)2

2
2 C 6 B

0010 1100 0110 1011 (from table)

(0010110001101011)2 (combine all


bits)

You might also like