Professional Documents
Culture Documents
DataRepresentation Notes
DataRepresentation Notes
DataRepresentation Notes
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.
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:
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.
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.
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 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 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:
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.
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.
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.
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
Combine all the bits in the same order to arrive at the answer:
(D28E)16 = (1101001010001110)2
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
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
Combine all the bits in the same order to arrive at the answer:
(7530)8 = (111101111000)2
To convert a binary string into Octal number, group the binary string into bits of 4, starting from the right.
Binary 11001100101
Octal 3145
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.
Hexadecimal 9 6 A F
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
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.
Octal 4 5 6 7 3 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
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
LSB
MSB
(200)10 = (11001000)2
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.
Remainder
LSD
MSD
(3456)10 = (D80)16
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.