0% found this document useful (0 votes)
13 views13 pages

Lecture 5-Data Representation

Uploaded by

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

Lecture 5-Data Representation

Uploaded by

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

DATA REPRESENTATION

Concepts of data representation in digital computers


In digital computers, the user input is first converted and transmitted as
electrical pulses that can be represented by distinct digits ‘1’ and ‘0’ before
processing. These two digits are referred to as binary digits or in short
bits.
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.
Reason for use of binary system in computer
It has proved difficult to develop devices that can understand or process
natural language directly due to the complexity of natural languages. It is,
however, possible to develop devices that can understand binary language.
Devices that read process and output data in digital form are used in
computers and other digital devices such as calculators.
Binary logic has therefore simplified the technology needed to develop both
hardware and software systems.
Other reasons for the use of binary are that digital devices are more reliable,
small in size and use less energy as compared to analog devices.

Bits, bytes, nibble and Word


Bits: a bit can be defined as a binary digit which can either be 0 or 1.it is the
basic unit of data or information in digital computers
Bytes: a group of bits (8) used to represent a character is called a byte. a
byte is considered as the basic unit of measuring memory size in computers.
Nibble: half a byte, which is usually a grouping of 4 bits, is called a nibble.
Word: two or more bytes make a word. The term word length is used as a
measure of the number of bits in each word.e.g. 16 bits, 32 bits, 64 bits etc.

1
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 into manageable form. This
helps to improve the processing speed and optimize memory usage.
Number systems and their representation
Number systems can be classified into four major categories:
1. Decimal number system
2. Binary number system
3. Octal number system
4. Hexadecimal number systems
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. X 10.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 three parameters
1. Absolute value
2. Place value or positional value.
3. Base value

The absolute value is the magnitude of a digit in a number. The place value
of a digit in a number refers to the position of the digit in that number. The
base value of a number also known as the radix, depends on the type of the

2
number system that is being used. The value of any number depends on the
radix.
Binary number system
Binary number system uses digits namely 1 and 0 to represent numbers.
Unlike in decimal numbers where the place values go up in factors of ten, in
binary number system, the place values increase by factors of two. Binary
numbers are written as X2.consider a binary number such as 1011 2. The right
most digit has a place value of 1x2 0 while the left most has a place value of
1x23.
Place Eights 23=8 Fours 22=4 Twos 21=2 Ones 20=1
values(2n)
Binary digit 1 0 1 1
The decimal equivalent of 10112 can be
N10= (1x23) + (0x22) + (1x21) + (1x20)
= (1x8) + (0x4) + (1x2) + (1x1)
N10 = 1110
Octal Number System
The octal number system consists of eight digits running from 0-7.the place
value of octal numbers go up in factors of eight from right to left.
Example: 72458
Place value 83=512 82=64 81=8 80=1
Octal digit 7 2 4 5
The decimal equivalent of 72458 can be:
N10= (7x83) + (2x82) + (4x81) + (5x80)
= (7x512) + (2x64) + (4x8) + (5x1)
N10 = 374910
Hexadecimal number system
This is a base sixteen number that consist of sixteen digits ranging from 0-9
and letters A-F where A is equivalent to 10,B to 11 upto F which is
equivalent to 15 in base ten system. The place value of hexadecimal number system goes up
in factors of sixteen.
Place value 162=256 161=16 160=1

3
Hexadecima 9 4 6
l digit
A hexadecimal number is usually denoted using 16 as a subscript or capital letter H to the right
of the number.
Base 10 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1
5
Base 16 0 1 2 3 4 5 6 7 8 9 A B C D E F

Example: 94B16
N10= (9x162) + (4x161) + (11x160)
= (9x256) + (4x16) + (11x1)
N10 = 237910

Conversion of numbers from one number system to another


1. Conversion between binary and decimal numbers
2. Converting octal number to decimal and binary form
3. Converting hexadecimal numbers to decimal and binary form

Conversion between binary and decimal numbers


Converting binary numbers to decimal numbers
 First write the place values starting from the right hand side.
 Write each digit under its place value.
 Multiply each digit by its corresponding place value.
 Add up the products. The answer will be the decimal number in base
10.

Example 1
Convert 1011012 to a base 10(decimal) number
Place value 25 24 23 22 21 20
Binary 1 0 1 1 0 1
digits

4
N10=(1x25) + (0x24) + (1x23) + (1x22) + (0x21) + (1x20)
= 32+0+8 + 4 + 0 + 1
N10 = 4510
Example 2
Convert 1001002 to a base 10(decimal) number
Place value 25 24 23 22 21 20
Binary 1 0 0 1 0 0
digits

N10=(1x25) + (0x24) + (0x23) + (1x22) + (0x21) + (0x20)


= 32+0+0 + 4 + 0 + 0
N10 = 3610
Converting decimal numbers to binary
The decimal number is continuously divided by 2.however, at each level of
the division, the remainder which is either a 1 or 0 is written to the right of
the quotient. Starting from the bottom upwards, read the series of the
remainder digits. The series of 1’s and 0’s obtained represent the binary
equivalent of the number.
Example 1
Convert 4510 into binary
2 45
2 22 R 1
2 11 R 0
2 5 R1
2 2 R1
2 1 R0
0 R1

Example 2
Convert 24710 into binary

5
2 247
2 12 R1
3
2 61 R1
2 30 R1
2 15 R0
2 7 R1
2 3 R1
2 1 R1
0 R1

24710= 111101112

Converting a binary fraction to decimal number


A decimal number which has both an integral and fractional part is called a
real number. The weight of the integral part of a real number increases
from right to left in factors of 10 while that of the fractional part decreases
from left to right in factors of 10-x.
Place value 21 20 . 2-1 2-2 2-3 2-4 2-5

Binary digit 1 1 . 1 1 0 1 1

Value in base 2 1 . 0.5 0.25 0.125 0.0625 0.0312


ten 5

Example 1
Convert 11.0112 to a decimal number
Place value 21 20 . 2-1 2-2 2-3

Binary digit 1 1 . 0 1 1

Value in base 2 1 . 0.5 0.25 0.125


ten
2x1=2.000
1x1=1.000
=3.00010

6
0.50 x 0 =0.000
0.25 x 1 = 0.250
0.125 x 1 =0.125
=0.37510
3.00010 + 0.37510 =3.37510
11.0112 =3.37510

Example 2
Convert 11.110112 to its decimal equivalent
310+0.8437510 = 3.8437510
11.110112 = 3.8437510

Converting a decimal fraction to binary


 Multiply the fractional part by 2 and note down the product.
 Take the fractional part of the immediate product and multiply it by 2
again.
 Continue this process until the fractional part of the subsequent
product is 0 or starts repeating the value of the original fractional part
of the number being converted.
 The binary equivalent of the fractional part is extracted from the
products by reading the respective integral digits from the top
downwards.
 Combine the two parts together to get the binary equivalent.

Example 1
Convert 0.37510 into binary form
0.375x2=0.750
0.750x2=1.500
0.500x2=1.000 (fraction becomes zero)
0.37510=0.0112
Example 2
Convert the decimal number 7.562510 into binary equivalent
2 7 Integral part
2 3 R1
7
2 1 R1
2 0 R1
710 =1112

Fractional part

0.5625x2=1.125
0.125x2=0.250
0.250x2=0.500
0.500x2=1.000
0.562510=0.10012
7.562510=111.10012
Example 3
Convert 0.4010 into its binary equivalent
Answer =0.01102 (recurring binary fraction)

Converting octal numbers to decimal and binary numbers


Converting octal numbers to decimal numbers
To convert a base 8 number to its decimal equivalent we use the same
method as we did with binary numbers. The maximum absolute value of an
octal digit is 7.e.g 982 is not a valid octal number because digits 8 and 9
are not octal digits, but 7368 is valid because all the digits are in the range of
0-7.
Example 1
Convert 5128 to its base 10 equivalent.
Place value 82=64 81=8 80=1
Octal digit 5 1 2
N10= (5x82) + (1x81) + (2x80)
= (5x64) + (1x8) + (2x1) =320+8+2
N10 = 33010
Example 2
Convert the octal number 11118 to its base ten equivalents
Place value 512 64 8 1
Octal digit 1 1 1 1

8
512x1=512
64x1= 64
8x1= 8
1x1= + 1
585
11118=58510

Converting octal numbers to binary numbers


To convert an octal number to binary, each digit is represented by 3 binary
digits because the maximum octal digit i.e. 7 can be represented with a
maximum of 3 digits.
Octal Binary
digit equivalents
0 000 Shows how to convert octal
1 001 numbers to binary numbers
2 010
3 011
4 100
5 101
6 110
7 111

Example 1
Convert the octal number 3218 to its binary equivalent
3=011
2=010
1=001
3218=0110100012
Example 2
Convert the octal number 5268 to a binary number

5=101

9
2=010
6=110
5268=1010101102
Example 3
Convert the octal number 3328 to its binary equivalent
3328=0110110102

Converting hexadecimal numbers to decimal and binary numbers


Converting hexadecimal numbers to decimal numbers
To convert a hexadecimal number to its base ten equivalent,we proceed as
follows:
1. First write the place values starting from the right hand side
2. If a digit is a letter such as an “A” write its decimal equivalent
3. Multiply each hexadecimal digit with its corresponding place value and
then add the products.

Example 1
Convert the hexadecimal number 11116 to its decimal equivalent
Place value 162=256 161=16 160=1
Hexadecima 1 1 1
l digit

256x1=256
16x1= 16
1x1= +1
273
11116=27310

Example 2
Convert the hexadecimal number A916 to its decimal equivalent
161=16 160=1
A 9
A in hexadecimal is equivalent to 1016
16x10=160

10
1x9= + 9
169
A916 = 16910

Example 3
Convert the hexadecimal number 1AD116 into its base ten equivalents
Place value 163=4096 162=256 161=16 160=1
Hexadecima 1 A D 1
l digit

4096x1=4096
256x10=2560
16x13=208
1x1= +1
6865
1AD116=686510
Converting hexadecimal numbers into binary numbers
Since F is equivalent to binary number 1111 2, the hexadecimal numbers are
represented using 4 digits.

Hexadecim Decimal Binary


al digit equivalent equivale
nt
00 00 0000
01 01 0001
02 02 0010
03 03 0011
04 04 0100
05 05 0101
06 06 0110
07 07 0111
08 08 1000

11
09 09 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111

The simplest method of converting a hexadecimal number to binary is to


express each hexadecimal digit as a four bit binary number and then
arranging to their corresponding positions.
Example 1
Convert 32116 into binary
Hexadecima 3 2 1
l digit
Binary 0011 0010 0001
equivalent

32116=0011001000012
Example 2

Hexadecima 5 E 6
l digit
Binary 0101 1110 0110
equivalent
5E616 =0101111001102
Exercise
Read and make notes about the following:
1. Symbolic representation using coding system
 Binary Coded Decimal
 Extended Binary Coded Decimal Interchange Code(EBCDIC)

12
 American Standard Code for Information Interchange(ASCII)
2. Representation of signed binary numbers
 Using ones complement

Using twos complement

13

You might also like