Lecture 5-Data Representation
Lecture 5-Data Representation
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
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
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
Binary digit 1 1 . 1 1 0 1 1
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
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
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)
8
512x1=512
64x1= 64
8x1= 8
1x1= + 1
585
11118=58510
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
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.
11
09 09 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
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
13