MODULE 4 Data Representation
MODULE 4 Data Representation
Program instruction and data are made up of a combination of three types of characters.
Alphabetic (A - Z), Numeric (0 - 9) and special (all other characters E.G @, #, $). The data and
program instructions are being stored character by character. Each character in storage has got
its electrical representation which uniquely identifies it.
All digital computers use some variation of binary numbering system for representation of
characters. The binary numbering system has only two digits 0 and 1. 1 denotes the presence of
electrical pulse and 0 denotes the absence of such a signal.
The computer is unable to understand the supplied data represented by these symbols. To make
communication possible between a computer and man, data must be coded in a form
understandable to the computer and the information supplied by a computer, as a result of data
processing, must be decoded in the form understandable to the user. The responsibility of coding
and decoding in a computer system lies with the input-output devices.
Number Systems
A number system is a set of symbols or numbers combined with rules for how these numbers are
used. The various number systems are:
Decimal number system
Binary number system
Octal number system
Hexadecimal number system.
Decimal System
This consists of ten digits 0 –9. Each digit has a digit value 0 to 9. Because the decimal system
is used almost universally, basic arithmetic performed by a person in one country is easily
understood by a person in another country.
In a decimal system each digit has a positional value determined by how many places to the left
or the right of the decimal point the digit is written.
Binary System:
This is a base two number system since it uses only two digits 0 and 1 called the binary digits.
Its lowest digit is 0 and the highest digit is 1 – one less than the base of 2. Internally, the
computer uses binary number system since the two digits 1 and 0 represent the two electrical
states, on and off.
Machine language uses binary number system to provide instructions for the CPU. It is the most
basic language for the computer. It requires no translation to be understood. Binary numbers
tend to be much longer than their decimal equivalents.
Programmers, who work in assembly language and in high-level languages that enable
programmes to reach down to the machine level, find it cumbersome to work with binary
numbers.
For this reason, two other systems, the octal system (base 8) and the hexadecimal system (base
16) – are used primarily because they make it convenient to abbreviate binary numbers.
Converting a decimal number to binary involves representing the decimal number using only the
digits 0 and 1, which are the base-two digits. Here's how you can convert a decimal number to
binary
Step 1 : Start with the decimal number you want to convert. Let's say we have the decimal
number 22
Step 2: Divide the decimal number by 2 and write down the quotient (result of division) and the
remainder (0 or 1). For example, when you divide 23 by 2:
23÷2 = 11 Remainder 0
Step 3: Take the quotient from Step 2 (in this case, 11), and repeat the division process until the
quotient becomes 0.
11÷2 = 5 Remainder 1
5÷2 = 2 Remainder 1
2 ÷ 2 = 1 Remainder 0
1 ÷ 2 = 0 Remainder 1
Step 4: Take the remainder and write it down. This will be the least significant bit (LSB) of your
binary representation. In our example, the LSB is 1.
Result : 10110
Step 2: Assign a place value to each digit in the binary number, starting from the right (the least
significant bit or LSB) and doubling the place value as you move to the left. For example:
1 (LSB) has a place value of 2^0 = 1.
1 to the left of it has a place value of 2^1 = 2.
0 to the left of that has a place value of 2^2 = 4.
1 to the left of that has a place value of 2^3 = 8.
1 to the left of that has a place value of 2^4 = 16.
Step 3: Multiply each binary digit by its corresponding place value and sum up the results. In our
example:
1*1=1
1*2=2
0*4=0
1*8=8
1 * 16 = 16
Step 4: Add up the results from Step 3 to get the decimal equivalent:
1 + 2 + 0 + 8 + 16 = 27
So, in decimal, the binary number 11011 is equivalent to 27.
Octal System:
It uses 8 digits from 0 – 7. Because 8 is an integral power of 2 i.e. 810 = 2310, one octal digit has a
value equivalent to that of a group of three binary digits and vice versa. This relationship
simplifies the programming of digital computers, since the octal system may be used in place of
the more cumbersome binary system.
Converting a decimal number to octal involves representing the decimal number using only the
digits 0 to 7, which are the base-eight digits.
Step 1: Start with the decimal number you want to convert.
For example decimal number 123.
Step 2: Divide the decimal number by 8 and write down the quotient (result of division) and the
remainder (a digit between 0 and 7). For example, when you divide 123 by 8:
123 ÷ 8 = 15 (remainder of 3)
Step 3: Take the remainder and write it down. This will be the least significant digit (LSB) of
your octal representation. In our example, the LSB is 3.
Step 4: Take the quotient from Step 2 (in this case, 15), and repeat the division process until the
quotient becomes 0.
15 ÷ 8 = 1 Remainder 7
1 ÷ 8 = 0 Remainder 1
Step 5: Write down the remainders in reverse order to get the octal representation. In our
example, the remainders are 1, 7, and 3. So, the octal representation of 123 is 173.
Hexadecimal Systems
This is a base 16 number system that uses 16 symbols; the digits 0 to 9, then the letters A to F to
represent the numbers 10 to 15. The number 16 is also an integral power of 2 that is, 1610 , 2410.
Thus, one hexadecimal digit has a value equivalent to that of a group of four binary digits and
vice versa.
Converting a decimal number to hexadecimal involves representing the decimal number using
the base-sixteen digits, which include the numbers 0-9 and the letters A-F. Here's how you can
convert a decimal number to hexadecimal:
Step 1: Start with the decimal number you want to convert. Let's say we have the decimal
number 255 as an example.
Step 2: Divide the decimal number by 16 and write down the quotient (result of division) and the
remainder (a digit between 0 and 15, which can be represented as 0-9 or 10 = A, 11= B, 12=C,
13=D, 14=E , 15=F). For example, when you divide 255 by 16:
Quotient: 15 (with a remainder of 15)
Step 3: Take the remainder and write it down in hexadecimal format. In our example, the
remainder is 15, which is represented as "F" in hexadecimal.
Step 4: Take the quotient from Step 2 (in this case, 15), and repeat the division process until the
quotient becomes 0.
Divide 15 by 16:
Quotient: 0 (with a remainder of 15)
Step 5: Write down the remainders in reverse order to get the hexadecimal representation. In our
example, the remainders are 15 and 15. So, the hexadecimal representation of 255 is "FF."
So, in hexadecimal, the decimal number 255 is represented as "FF."
Step 1: Start with the hexadecimal number you want to convert. Let's say we have the
hexadecimal number "1A" as an example.
Step 2: Assign a place value to each digit in the hexadecimal number, starting from the right (the
least significant digit or LSD) and multiplying the digit by the appropriate power of 16 as you
move to the left. For example:
"A" (LSD) has a place value of 16^0 = 1.
"1" to the left of it has a place value of 16^1 = 16.
Step 3: Convert any hexadecimal letters (A-F) to their decimal equivalents:
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
In our example, "A" is equivalent to 10 in decimal.
Step 4: Multiply each hexadecimal digit (including the converted letters) by its corresponding
place value and sum up the results. In our example:
"A" (converted to 10) * 1 = 10
"1" * 16 = 16
Step 5: Add up the results from Step 4 to get the decimal equivalent:
10 + 16 = 26
So, in decimal, the hexadecimal number "1A" is equivalent to 26.
Exercises
(i) Convert the following numbers to the indicated numbering system.
Representing Characters
Character representation refers to the way non-numeric data, such as a letter of the alphabet or a
punctuation mark is represented by a series of bits. Character representation code, simply
referred to as code is a series of bits that represents a letter, symbol or numerical.
The three character representation codes most widely used are ASCII, ANSI and EBCDIC. A
fourth code Unicode has been proposed for future world wide use.
Unicode: is a 16 -bit code that can represent 65000 different characters. It can represent any
character in every language used today.
Compression Techniques
Characteristics:
Data Reduction: Compression reduces the size of files, which is crucial for efficient storage
and transmission.
Lossless vs. Lossy: There are two main types of compression: lossless (no data loss) and
lossy (some data loss).
Algorithms: Various compression algorithms are used, including Huffman coding, Run-
Length Encoding (RLE), and Deflate (used in ZIP files).
Compression Utilities: Software tools like WinZip, 7-Zip, and gzip are used for compressing
and decompressing files.
Applications:
File Transfer: Compression reduces the time and bandwidth required to transfer files over the
internet.
Backup and Archiving: Compressing files before backup reduces storage space requirements.
Multimedia Streaming: Lossy compression is used for streaming audio and video to optimize
bandwidth usage.
Efficient Storage: Compression is essential in reducing the storage space needed for large
datasets, databases, and archives.
File formats and compression techniques are fundamental to digital data management.
Understanding the characteristics and applications of formats like JPEG, MP3, PDF, and various
compression methods is essential for effective data handling, storage, and transmission in diverse
domains. These technologies continue to evolve, shaping how we interact with digital
information in an increasingly interconnected world.