DataRepresentation Notes

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

DATA REPRESENTATION

Computer is a machine that processes the data that we provide it. It allows you to view, listen, create, and
edit information in documents, images, videos, sound, spreadsheets and databases. It also lets you
compute and calculate numerical information and send and receive information over networks.
Fundamental to all of this is that the computer has to represent that information in some way inside the
computer’s memory, as well as storing it on disk or sending it over a network.

We know that computers understand only the binary language, i.e, the language of 0s and 1s. How does it
read and process instructions as well as data if all of this has to be given only as a high or a low electrical
signal to the processor? At the most basic level, 0 and 1 can represent 2 quantities. How do we then
express numbers from 2 to 9? And how about larger quantities as well as instructions such as add/subtract
etc?
In order to represent more numbers, we use more digits, just like the decimal number system. But since
computer understands only binary number system, related systems such as Hexadecimal and Octal came
to be used.

Base of a Number System

All of us are familiar with the decimal number system. Any number system has a Base, that is the number of
unique digits available in the system. In decimal number system, we can uniquely represent 0 to 9. Hence
the base of the system is 10. The Base is also known as the Radix of the number system.
Let us look at the unique digits used by the different number systems:

Decimal Number System

How do we create bigger quantities using only the 10 digits that we know? We do it by giving weight to the
position of the number or its place value.

Consider this example:

6 has the most weight as it is multiplied by 100 in this example. Hence, it is known as the most significant
digit or MSD. 4 has the least weight as it is multiplied by 1/1000. Hence, it is known as the Least Significant
Digit or LSD.
Depending on the position or placement of the digit in the number, we give it a weight, starting from 100 and
we keep increasing the power by 1. For the decimal part, we start at 10-1 and we keep decreasing the value
of the power by 1. We use 10 because the radix is 10 for decimal numbers.

Binary Number System

Consider this binary number example:

Here, the Most Significant Bit (MSB) is 1 on the left most and the Least Significant Bit (LSB) is 1 on the right
most. Instead of Base 10 that we saw in Decimal system, we use Base 2 for binary number system.

Octal Number System

Octal number system has a base of 8, allowing digits 0 to 7 to be used. Just like the binary and decimal
number systems, octal number system is also a positional value system. Here, we use Base 8 instead of 10
or 2.
Consider this octal number example:

Hexadecimal Number System

Hexadecimal number system has a base of 16, allowing digits 0 to 9 to be used. Digits A to F are used to
represent the remaining values, from 10 to 16. This is because unique symbols are needed unlike in the
decimal system, where we start adding weight to the existing digits (10, 11 etc). Hexadecimal system also is
positional in nature. Consider this hexadecimal number example:

Comparison of Different Number Systems


Number Conversions from other systems to Decimal

(i) Binary to Decimal Number Conversion

Any binary number can be converted by using the place value and weights of the binary bits in the number.
Example: Convert (110.11)2 into a decimal number.

Decimal value of (110.11)2 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 1 x 2-2


= 4 + 2 + 0 + 0.5 + 0.25
= (6.75)10
(ii) Octal to Decimal Number Conversion

Remember, a valid octal number contains digits from 0 to 7 only. We use the place values of the numbers
to convert it into a decimal number.
Example: Convert (236.705)8 into a decimal number.

Decimal value of (236.705)8 = 2 x 82 + 3 x 81 + 6 x 80 + 7 x 8-1 + 0 x 8-2 + 5 x 8-3


= 128 + 24 + 6 + 7/8 + 5/512
= 158 + 0.875 + 0.01
= (158.885)10

(iii) Hexadecimal to Decimal Number Conversion

Hexadecimal number contains digits from 0 to 9 and alphabets A to F. We substitute values 10 to 16 when
we encounter these alphabets in the number. We use the place values of the numbers to convert it into a
decimal number.
Example: Convert (ABC.4)16 into a decimal number.

Decimal value of (ABC.4)16 = A x 162 + B x 161 + C x 160 + 4 x 16-1


= 10 x 256 + 11 x 16 + 12 x 1 + 4 x 0.0625
= 2560 + 176 + 12 + 0.25
= (2748.25)10

Number Conversions from Hexadecimal to Octal and Vice Versa

(i) Hexadecimal to Binary Number Conversion

In order to convert a hexadecimal number to binary, we just have to express each of the hexadecimal digits
in bits of 4. We use 4 bits because, in order to express all the numbers from 0 to F present in Hexadecimal,
we need 4 bits maximum. We can use the table to do this conversion.
Example: Convert (D28E)16 into a binary number.

Hexadecimal D 2 8 E

Binary 1101 0010 1000 1110

Combine all the bits in the same order to arrive at the answer:
(D28E)16 = (1101001010001110)2

(ii) Binary to Hexadecimal Number Conversion

To convert a binary string into its Hexadecimal equivalent, group the binary string into bits of 4, starting from
the right.

Binary 11001100101

Hexadecimal 665

(iii) Octal to Binary Number Conversion

In order to convert an octal number to binary, we rewrite each digit of the number as a binary number with 3
bits. We use 3 bits because, in order to express the maximum digit of 7 in Octal, 3 bits are required.
Example: Convert (7530)8 into a binary number.

Octal 7 5 3 0

Binary 111 101 111 000

Combine all the bits in the same order to arrive at the answer:
(7530)8 = (111101111000)2

(iv) Binary to Octal Number Conversion

To convert a binary string into Octal number, group the binary string into bits of 4, starting from the right.

Binary 11001100101

Octal 3145

(v) Hexadecimal to Octal Number Conversion

Here, we first convert the hexadecimal number into binary number. Then, we regroup the bits in the binary
number into sets of 3 and rewrite it as octal.
Example: Convert (96AF)16 into an octal number.

First, convert the given hexadecimal number into binary:

Hexadecimal 9 6 A F

Binary 1001 0110 1010 1111

(96AF)16 = (1001 0110 1010 1111)2

Regroup the binary number into sets of 3, starting from the right most bit:
(1001 0110 1010 1111)2 = (1 001 011 010 101 111)2
The last group has only one bit - 1, which is read as 001:
(1001 0110 1010 1111)2 = (113257)8

(vi) Octal to Hexadecimal Number Conversion

Here, we first convert the octal number into binary number. Then, we regroup the bits in the binary number
into sets of 4 and rewrite it as a hexadecimal number.

Example: Convert (456732)8 into a hexadecimal number.

First, convert the given octal number into binary:

Octal 4 5 6 7 3 2

Binary 100 101 110 111 011 010

(456732)8 = (100 101 110 111 011 010)2

Regroup the binary number into sets of 4, starting from the right most bit:
(100 101 110 111 011 010)2 = (10 0101 1101 1101 1010)2
The last group has only two bits - 10, which is read as 0010:
(100 101 110 111 011 010)2 = (25DDA)16

Number Conversions from Decimal to other Systems

(i) Decimal to Binary Conversion

In order to convert a decimal number into binary, we repeatedly divide the number by 2, since 2 is the
binary radix. We note down the remainder every time we divide. The last remainder is considered MSD.
Example: Convert (43)10 into a binary number.
Remainder
LSB

MSB

(43)10 = (101011)2

Example: Convert (200)10 into a binary number.


Remainder

LSB

MSB

(200)10 = (11001000)2

(ii) Decimal to Octal Conversion


In order to convert a decimal number into octal, we repeatedly divide the number by 8, since 8 is the octal
radix. We note down the remainder every time we divide. The last remainder is considered MSD.

Example: Convert (159)10 into an octal number.


Remainder

LSD

MSD

(159)10 = (237)8
Example: Convert (2019)10 into an octal number.
Remainder
LSD

MSD

(2019)10 = (3743)8
(iii) Decimal to Hexadecimal Conversion

In order to convert a decimal number into a hexadecimal number, we repeatedly divide the number by 16,
since 16 is the hexadecimal radix. We note down the remainder every time we divide. The last remainder is
considered MSD.

Example: Convert (3456)10 into a hexadecimal number.


Any remainder in the range 10 to 15 is represented by the corresponding alphabet symbol in hexadecimal.

Remainder

LSD

MSD

(3456)10 = (D80)16

Example: Convert (303)10 into hexadecimal.

Remainder

LSD

MSD

(303)10 = (12F)16
Character Representation in Computers

In addition to numerical data, a computer must be able to handle instructions and character/string
information. In effect, a computer must understand alphanumeric values which include A - Z, a - z, 0 to 9,
special characters such as &, + etc. In order to enable the computer to understand these values, they are
encoded into 7 bit strings in a standard format. This standard is known as ASCII (American Standard Code
for Information Interchange).

Using 7 bits, 128 values could be represented using ASCII. The table below shows the different
alphanumeric values that are represented.

By increasing the bit length of the binary string, more characters could be represented and this lead to
multiple versions of ASCII. In order to maintain a uniform standard across different countries as well as to
have a standard means of encoding all possible characters, Unicode was created. Unicode is an
international coding standard that contains all possible language alphabets apart from the basic ASCII code.
The first 128 characters of Unicode are the same as that of ASCII.

You might also like