Data Representation Tutorial 1
Data Representation Tutorial 1
Data Representation……..tutorial_1
For Computer Science students’
Hopefully, all of you go through the previous uploaded materials. In this material we discuss about various number
systems, conversion from one number system to other.
The technique to represent and work with numbers is called number system. In digital representation, various number
systems are used. The most common number systems used are decimal, binary, octal and hexadecimal number system.
1. Decimal Number System(DEC):- The decimal number system (Base 10) is composed of 10 numbers or symbols (Deca
means 10, that is why this system is called decimal number system). It is also known as base – 10 number system as it has 10
digits.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Unfortunately, the decimal number system does not lend itself convenient implementation in digital systems. Every digital
systems uses the binary number system.
2. Binary Number System(BIN):- In the binary number system (Base 2) there are only two symbols 0 and 1. It is Base – 2
system.
Symbols: 0, 1
3. Octal Number System (OCT):- In the octal number system (Base 8) there are eight unique symbols. It is Base – 8 system.
Symbols: 0, 1, 2, 3, 4, 5, 6, 7
4. Hexadecimal Number System(HEX):- The hexadecimal system uses Base 16. Thus it has 16 possible symbols.
Symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
(Here actually A means 10 in decimal, B means 11, C means 12, D means 13, E means 14 and F means 15 in decimal)
In addition to binary and decimal number system, octal and hexadecimal number systems are also used in digital systems for
representing large binary numbers.
In a digital system, these number systems may be in use at the same time, so that an understanding of the system operation
requires the ability to convert from one number system to another.
(1) When you convert from decimal number system to any other number systems (means in left side – Decimal )
(2) Convert from any other number systems to decimal number system (means in right side – Decimal )
For the above conversions, we will follow division by For the above conversions, we will follow
the base (of the number system on right side) way: following technique:
as follows:
divide the number by 2 as Base of Binary is 2 Here Base indicates the base of the number system
See examples…………
Decimal to Binary conversion:-
Example:- Convert 43 to its binary equivalent.
OR (43)10 (?)2
solution)
Divide the number by 2 (Base of the right hand side number system) note down the remainder then again divide the quotient
by 2 note down the remainder (obviously integer division)…… and that process will continue till the quotient become 0.
= ( 101011 )2
So, the answer is (43)10 = ( 101011 )2
OR (101011)2 ( ? )10
Solution)
positions 5 4 3 2 1 0
= 1 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
= 32 + 0 + 8 + 0 + 2 + 1
= ( 43 )10
OR (266)10 (?)8
solution)
Divide the number by 8 (Base of the right hand side number system) note down the remainder then again divide the quotient
by 8 note down the remainder (obviously integer division)…… and that process will continue till the quotient become 0.
= ( 412 )8
OR (412)8 ( ? )10
Solution)
positions 2 1 0
= 4 x 82 + 1 x 81 + 2 x 80
= 256 + 8 + 2
= ( 266 )10
OR (578)10 (?)16
solution)
Divide the number by 16 (Base of the right hand side number system) note down the remainder then again divide the
quotient by 16 note down the remainder (obviously integer division)…… and that process will continue till the quotient
become 0.
= ( 242 )16
Another Example:-
OR (423)10 (?)16
solution)
= ( 1A7 )16
OR (242)16 ( ? )10
Solution)
positions 2 1 0
= 512 + 64 + 2
= ( 578 )10
OR (98AC)16 ( ? )10
Solution)
positions 3 2 1 0
= ( 39084 )10
NOW, you think about the conversion from Binary to Octal then !!!!!!!!
First: Convert the number to its decimal equivalent (i.e. Binary Decimal)
Let’s see…
OR (100111010)2 ( ? )8
Solution)
positions 8 7 6 5 4 3 2 1 0
= 1 x 28 + 0 x 27 + 0 x 26 + 1 x 25 + 1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20
= 256 + 0 + 0 + 0 + 32 + 16 + 8 + 0 + 2 + 0
= ( 314 )10
Now, second: we convert the above decimal number to its octal equivalent. (i.e. Decimal Octal)
OR (472)8 ( ? )2
First: convert the octal number to its decimal equivalent (i.e. Octal Decimal )
then Second: convert the decimal number to its equivalent binary (i.e. Decimal Binary)
Let’s see…..
positions 2 1 0
= 4 x 82 + 7 x 81 + 2 x 80
= 256 + 56 + 2
= ( 314 )10
= (100111010)2
Let’s see….
OR (10011101)2 (?)16
solution)
positions 7 6 5 4 3 2 1 0
= 1 x 27 + 0 x 26 + 0 x 25 + 1 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
= 128 + 0 + 0 + 16 + 8 + 4 + 0 + 1
= ( 157 )10
OR (247)8 (?)16
positions 2 1 0
= 2 x 82 + 4 x 81 + 7 x 80
= 128 + 32 + 7
= ( 167 )10
Now, we can convert ( 167 )10 to its hexadecimal equivalent i.e. Decimal Hexadecimal
OR (A7)16 (?)8
positions 1 0
= 160 + 7
= ( 167 )10
NOW, there is an easy way to convert from Binary to Octal and Binary to
Hexadecimal………..see….
For that you should know the binary representation of 1 to 15 (for easy conversion):
Similarly, to represent first four numbers (i.e. 0, 1, 2, 3) in binary two bits are
required ( as 22 = 4 )
i.e. if we want to represent ‘0’ in two bits format then we write 00, for three bits we write 000 and for four bits we write
0000.
Similarly, if we write ‘2’ in binary 10 , if we want to write it in three bits format then 010, for four bits format it is 0010.
Don’t try to memorize the above………………just follow the following technique to remember:
suppose you want to write binary equivalent from 0 to 15 then how many numbers are there?
Yes, 4 bits as 24 = 16
(ii) then you write two zero’s and two one’s alternatively in the 2nd bit position for all numbers ….see..
(iii) then you write four zero’s and four one’s alternatively in the 3rd bit
position for all numbers ….see..
(11010110)2 ( ? )8
First you grouped the digits into groups of three bits starting from right hand side (i.e. LSB – Least Significant Bit)
See………… (if there is less than three digits in the left most group then insert zeros )
0 1 1 0 1 0 1 1 0
0 inserted as
there are two
digits in left
most group
now you can write the decimal equivalent of each group i.e.
0 1 1 0 1 0 1 1 0
3 2 6
(326)8 ( ? )2
Here, we represent each digit of the octal number in its binary equivalent of 3 bits form…..see….
3 2 6
So, the answer is (326)8 ( 11010110 )2 [ discard left most zeros’ while writing answer ]
(1010111010)2 ( ? )16
First you grouped the digits into groups of four bits starting from right hand side (i.e. LSB – Least Significant Bit)
See………… (if there is less than four digits in the left most group then insert zeros )
0 0 1 0 1 0 1 1 1 0 1 0
two 0 ‘s inserted
as there are two
digits in left
most group
now, you can write the decimal equivalent of each group i.e.
0 0 1 0 1 0 1 1 1 0 1 0
2 11 means 10 means
B in hex A in hex
(9F2)16 ( ? )2
Here, we represent each digit of the hexadecimal number in its binary equivalent of 4 bits form…..see….
9 F 2 [ F means 15 in decimal ]
So, the answer is (9F2)16 ( 100111110010 )2 [ discard left most zeros’ while writing answer here
left most zero’s not present ]
(1646)8 ( ? )16
First, we convert the Octal number to its equivalent binary ( in 3 bits form)……
1 6 4 6
now, grouped the digits into groups of four bits starting from right hand side of the binary number
0 0 1 1 1 0 1 0 0 1 1 0
3 10 means A 6
So, the answer is (1646)8 ( 3A6 )16
Now, Hexadecimal to Octal Conversion ( easier way):-
(7F5C)16 ( ? )8
First, we convert the Hexadecimal number to its equivalent binary ( in 4 bits form)……
7 F 5 C
now, grouped the digits into groups of three bits starting from right hand side of the binary number ( discard left
most zero’s if any)
1 1 1 1 1 1 1 0 1 0 1 1 1 0 0
7 7 5 3 4