# Python Fundamentals – Data Representation

## Python Fundamentals – Data Representation

INTRODUCTION

We human beings commonly use the deci­mal number system consisting of digits 0,1, 2, 3, 4, 5, 6, 7, 8 and 9. But in computers, instructions as well as data are stored in binary form. The binary number system consisting of digits 0 and 1 because binary digits 0 and 1 can be easily created by an electrical switch. If the switch is closed it could be 1 and if it is open it could be 0. The computer is required to store the following types of data.

• Numbers used in arithmetic computa­tions.
• Alphabets used in symbolic instruc­tions and some data processing.
• Special characters or Symbols like #, \$, %, &, etc. used in some special cases.

But since binary numbers are awful to see and work with, octal and hexadecimal num­bers are now widely used to compress long strings of binary data.
This Chapter, discusses different types of number systems. We shall also learn how numbers in one number system can be con­verted into another form of number system.

NUMBER SYSTEMS
The most widely used number system is the positional number system. In this system the position of a digit indicates the signifi­cance to be attached to that digit. Positional number systems has a radix or a base. Decimal number, binary number, hexadecimal number, and octal number systems are all positional number systems. The non- positional number system is the Roman number system. This number system is difficult to use as it has no symbol for zero. The idea of a positional number system was the greatest invention of this age and this came from India.
Conversion from one number system to another number system is required because we human beings are so accustomed to decimal number system that entering data into the computer in binary, octal or hexadecimal number system seems very difficult for us. Therefore, the alternative lies in letting users enter data in decimal number system only. The computer is then expected to convert the decimal numbers into other number system which it understands for further calculations.

DECIMAL NUMBER SYSTEM
The ten fingers are the most convenient tools human beings have always used in count­ing. Decimal number system followed the use of ten fingers. In the decimal number sys­tem there are ten digits which are used to form decimal numbers. Ten unique symbols 0,1, 2, 3,4, 5, 6, 7, 8 and 9 are used to represent ten decimal digits.

The decimal number system is also called base-10 number system. The base or radix of a number system is defined as the number of digits it uses to represent numbers in the system. Since the decimal number system uses ten digits, from 0 to 9, its base or radix is lO.The weight of each digit of a decimal number depends on its relative position within the number. This is explained by the following example:
Example 1:
Explain the weight of each digit of the number 6598.
Solution:
6598 = 6000 + 500 + 90 + 8
= 6 x 103 + 5 x 102 + 9 x 101 + 8 x 10°
Thus we can see that from the right hand side:
The weight of the 1st digit of the number = 1st digit x 10°
The weight of the 2nd digit of the number = 2nd digit x 10
The weight of the 3rd digit of the number = 3rd digit x 102.                            .■
The weight of the 4th digit of the number = 4th digit x 103.
The expressions in a general form can be written as follows:
The weight of the nth digit of the number = nth digit x 10n-1
or = nth digit x (Base)n-1
POINTS TO PONDER
Many ancient cultures, such as Egyptian hieroglyphs used a purely decimaPsystem. These hieroglyphs were a writing system which was used by the ancient Egyptians.

BINARY NUMBER (BASE-2) SYSTEM
The binary number system uses only two digits, 0 and 1. In short, a binary digit, is called a bit. The storing or computing electronic elements of a computer have only two stable states. The output of such electronic circuits at any time is either HIGH or LOW. These states can be represented by 1 and 0 respectively, that is HIGH is represented by 1 and LOW by 0. Due to this characteristic of electronic circuits, a computer can understand information composed of only Os and Is. So, all computers perform their internal manipulations on binary digits only. But programmers use data and other information in the form of decimal digits, alphabets and special symbols. This information is con¬verted to binary codes within the computer because a digital computer can operate on bits only. Thus, knowledge of the binary number system is needed to understand the working principle of a digital computer.

Binary Representation of a Number
In the binary number system zero is represented by 0 and one by 1. There is no digit in the binary number system to represent numeral 2. Using the positional technique, we can write 2 as 10. Three can be written as 11. Four is represented by 100. The weight of each binary bit of a binary number will depend on its relative position within the number. We will learn it in the following examples:

Example 2
Explain the weight of each bit of the binary number 1110.
Solution
The weight of the 1st bit from the right hand side of the binary number = 1st bit x 2° or = 0x2°
The weight of the 2nd bit of the number = 2nd bit x 21 = 1 x 21
The weight of the 3rd bit of the number = 3rd bit x 22 = 1 x 22
The weight of the 4th bit of the number = 4th bit x 23 = 1 x 23
1110 (Binary Number) = 1 x 23 +1 x 22 + 1 x 21 + 0 x 2°
= 8 + 4 + 2 + 0
= 14 (Decimal Number)
POINTS TO PONDER
In 1679, binary number system was discovered by Gottfried Leibniz.

Conversion of a Binary Number to a Decimal Number Equivalent
To convert a binary number to its decimal equivalent, we do the following:
We know that the weight of the nth bit of the number from the right hand side= nthbitx2n-1
We mark each bit position. Using this, we give the weight of each bit of the number based on its position. The sum of the weights of all bits will be the equivalent decimal number. Let us read the following examples:

Example 3
Convert 10 (binary number) to its decimal equivalent.
Solution
Counting from the right hand side, first bit = 0
Its weight= 0x20=0
2nd bit= 1
Its weight= 1×21=2
The decimal equivalent =1 x 21 + 0 x 2°=2+0 = 2
Table 3.1 shows binary equivalents of some typical decimal numbers from 0 to 128.

Example 4
Convert 11010 (binary number) to its decimal equivalent.
Solution
Bits position from the right hand side:
1 1 0 1 0
5th 4th 3rd 2nd 1st
11010 (Binary Number) =1×24 + 1×23 + 0x22 +1×21 + 0x2°
= 16 + 8 + 0 + 2 + 0 = 26 (Decimal Number).

Example 5
Convert 1011 (binary number) to its decimal equivalent.
Solution
Bit position from the right hand side:
1 0 1 1
4th 3rd 2nd 1st
1011 (Binary Number) = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 2°
=8+0+2+1
= 11 (Decimal Number).
We use the following technique. To indicate the base of a number, we uses suffix, i.e., (11)1o = (1011)2
We use suffix 10 to indicate that it is a decimal number. We use suffix 2 to indicate a binary number.

Conversion of a Decimal Number to a Binary Number
Here, we use the following method:
Step 1 The decimal number is divided by 2 successively. The quotient and the remainder are noted down at each stage.
Step 2 The quotient of the preceding stage is divided by 2 at the next stage. The process is repeated until the quotient becomes zero.
We shall learn the method by reading the following examples.

Example 6
Convert the decimal number 43 to its binary equivalent.
Solution

Therefore, 43 (Decimal Number) = 101011 (Binary Number). Note that the first remain¬der is the Least Significant Bit (LSB) and the final remainder is the Most Significant Bit (MSB).

Example 7
Convert the decimal number 73 to binary.
Solution

The 73 decimal number = 1001001 (Binary Number).
By converting binary to decimal, we can counter check the correctness of the result.
For example,
(1001001)2 = 1×26 + 0x25 + 0x24 + 1×23+ 0x22 + 0x21 + 1×2°
= 64 + 0 + 0 + 8 + 0 + 0 + 1 = 73

Example 8
Convert the decimal number 155 to binary.
Solution

16 is the radix or base in the hexadecimal number system. Its digits are from 0 to 9 and A to F. Decimal number 10 (ten) is represented by A, 11 by B, 12 by C, 13 by D, 14 by E and 15 by F.
Four binary bits are used to represent a hexadecimal number. For example, B is represented by 1011 as hexadecimal equivalent.
If a number consists of two or more than two digits, then in hexadecimal number system, each digit is represented by four bits. For example, 87 in hexadecimal is represented by 1000 0111 in binary coded hexadecimal representation. Table 3.2 shows hexadecimal numbers and their binary coded hexadecimal representation.

Table 3.2 Hexadecimal Numbers and their Binary Equivalents

Conversion of Hexadecimal Numbers to Decimal Numbers
We use the weights of digits of the hexadecimal number.
The weight of nth digit of the number from the right hand side = nth digit x (Base)n-1
The base here is 16.

Example 9
Convert the hexadecimal number B7 to its equivalent decimal number.
Solution
7 is the 1st digit of the number from the right hand side. Its weight is 7 x 16°.
B is the 2nd digit of the number from the right hand side. Its weight is B x 161, or 11×161
where 11 is decimal value of B.
Therefore, B7 = B x 161 + 7 x 16°
= 11×16 + 7×1
= 176 + 7 = 183 (decimal)
Convert the hexadecimal number (2B6D) to its equivalent decimal number.
2B6D = 2 x 163 + B x 162 + 6 x 161 + D x 16°
= 2 x 4096 + 11 x 256 + 6 x 16 + 13 x 1
= 8192 + 2816 + 96 + 13
= 11117 (decimal)

Conversion of a Decimal Number to a Hexadecimal Number
For the conversion of a decimal number to an equivalent hexadecimal number, the deci¬mal number is divided by 16 successively. The process is repeated until the quotient becomes zero

Example 10
Convert decimal number 920 to an equivalent hexadecimal number.
Solution

Conversion of Binary Numbers to Hexadecimal Numbers
Hexadecimal number system has 16 as its base. But 16 = 24. To convert a binary number to hexadecimal, we make groups. Each group contains 4 bits of the binary number. Each group of 4 bits is converted to its hexadecimal equivalent. We shall understand it by the following examples.

Example 11
Convert the binary number 01101110 to its equivalent hexadecimal number.
Solution
(01101110)2 = (0110) (1110) {groups of 4 bits} = 6 E = 6 E

Example 12
What is hexadecimal equivalent of binary number 101001100.
Solution

Conversion of Hexadecimal Number to Binary Number
In order to convert a hexadecimal number to its equivalent binary number, we put the binary value of each digit in hexadecimal number.
Example 13
Give the binary equivalent of 6B.
Solution

OCTAL NUMBER SYSTEM
Octal number system has a base 8. Eight digits are 0,1, 2, 3, 4,5, 6 and 7. The next num¬bers after 7 in octal number system will be 10,11,12,13,14 … .
An octal number is represented by a group of three binary bits. If it contains two or more digits, then each digit is represented by a group of three bits each.
Octal 47 is represented by 100 111 and 3558 by Oil 101 101. Table 3.3 shows octal num-bers and their binary representations.

Conversion of Octal Numbers to Decimal Numbers
We know that conversion of a number to decimal equivalent we make use of the following expression:
The weight of the nth digit of the number from right hand side = nth digit x (Base)n-1.
For example,
558 = 5 x 81 + 5 ,x 8° = 40 + 5 = 45 in decimal

Conversion of Decimal Numbers to Octal Numbers
To convert a decimal number to an equivalent octal number, we repeatedly divide by 8 till quotient is zero.

Example 14
Convert decimal number 64 to its equivalent octal number.
Solution

Conversion of Binary Numbers to Octal Numbers
For binary to octal conversion, we make group of 3 bits starting from right to left. Then each group of 3 bits is converted to its octal equivalent value.
For example, to convert the binary number 1011102 to its equivalent octal number, we form groups of 3 bits each starting from right to left.
Thus
(101110)2 = 101 110
= 5 6

Conversion of Octal Numbers to Binary Numbers
An octal number can be converted to its equivalent binary number where each digit of the given octal number is converted to its 3-bits binary equivalent.
For example, (37)8 = 011 111

Conversion of Hexadecimal to Octal Number
To convert hexadecimal to octal number, we do the similar operation. First each digit of hexadecimal number is given its equivalent 4 bits and these are placed side by side. Then, we form groups of 3 bits each starting from right most bit. Then, each group of 3 bits is given its equivalent octal digit.
For example (2B)16 = 0010 10112
=(101) (Oil)
= 5 3
= 538

Conversion of Octal to Hexadecimal Number
For this, first convert each digit of octal number to its equivalent 3 bits binary value and place them side by side.
Now form groups of 4 bits from right most side and give its hexadecimal equivalent digits.
Thus 538 = 101 0112
= 0010 10112
= 2B16

Conversion of Hexadecimal to Binary Number
To convert a hexa-decimal number to its equivalent binary number each digit of the given hexadecimal number is converted to its 4-bit binary equivalent.
For example, convert the hexadecimal number (B.F4)16 to its equivalent binary number.
(B.F4)16 = (1011).(1111) (0100)
= (1011.11110100)2
= (1011.111101)2
For example, convert the hexadecimal number (39.A5)16 to its equivalent binary number.
(39.A5)16 = (0011)(1001).(1010) (0101)
= (00111001.10100101)2
= (111001.10100101)2

COMPLEMENTS OF A NUMBER
Complements are used in the digital computers in order to simplify the subtraction operation and for the logical manipulations.
The r’s Complement
The r’s complement of a positive numbers N is defined as C-N. Where ‘ r is the base and n is the number of digits in the integer part of the number N.
The (r-l)’s Complement
The (r-l)’s complement of a positive number N can be obtained by using the following
formula:
rn – rm -N
where r is the base and n is the number of digits in the integer part and m is the number of digit in fraction part.

Types of Complements
For each radix-r system, there are two types of complements:
The radix complement is referred to as the r’s complement and the diminished radix complement is referred to as (r-l)’s complement.
The binary system with a base r = 2. So the two types of complements for the binary system are 2’s complement and l’s complement.
Similarly for an octal system we have 8’s complement and 7’s complement. For a decimal system we have r = 10 and the types of complements are 10’s complements and 9’s complement.

1’s Complement
To get the l’s complement of a binary number, we need to subtract each bit of the binary number from 1. For example, the l’s complement of the binary number Oil is 100. The l’s complement of 0001 is 1110. Thus, we can say that the l’s complement of a binary number is formed by changing each 1 to 0 and each 0 to 1.

Example 15
Find the l’s complement of the binary number 101100.
Solution
For this, replace 0 by 1 and 1 by zero.
The 1’s complement of 101100 = 010011

2’s Complement
The 2’s complement of a binary number is obtained by first getting l’s complement of the number and then add 1 to this number. Thus,
The 2’s complement of a binary number = Its 1’s complement + 1.
The 2’s complement of 10110 = 01001 + 1 = 01010

FLOATING POINT NUMBER REPRESENTATION
A number which has both an integer part as well as fractional part is called real number or floating point number. For example, 0.756,1.23, 9.2445, 567.890, etc., are all floating point decimal numbers. Similarly, binary real numbers are 1.101,110.111, 0011.011, etc. The part which is to the left of the dot (decimal) is the integer part and number part which is to the right of the dot is called the fractional part. There are two ways of repre¬senting floating point numbers in computers. These are:
1. Fixed Point Representation
2. Floating Point Representation

Fixed Point Representation
In a fixed point representation of numbers, the binary or decimal point is assumed to be at the extreme right or left of the number. If the binary or decimal point is at the extreme right, the number is an integer. If the binary or decimal point is at the extreme left, the number is a fraction. This is not a popular method of representation these days because in this method the programmer has to keep track of the location of the decimal or binary point which is a tedious job.

Floating Point Representation
Unlike the Fixed Point Representation, in Floating Point Representation, the decimal point is not assumed to be at a fixed place. In fact a second register is used to store the number that specifies the position of decimal point in the number stored in first register. This will be more clear as you read on.
The real number 873.99 can also be written as 8.7399 x 102. Similarly, the real number
0. 002635 can be written as 2.635 x 10″3. Such a representation of floating point numbers is known as scientific representation. Thus in scientific representation, the number is expressed as a combination of a mantissa (or fraction) and an exponent. For example, the number in 2.635 x 10’3, 2 is the mantissa part and (-3) is the exponent part.
In floating point representation of numbers, the real numbers are stored in computers in the scientific representation form. Thus, in the computer floating point numbers are represented by two parts:
(a) Mantissa part
(b) Exponent part
The mantissa part consists of the signed number and the exponent part indicates the position of decimal in the number.
For example, the decimal number 4598.01 (0.459801 x 104) in floating point presentation will be as follows:

The zero in the sign bit indicates positive number. The decimal point shown in the mantissa part is not represented in physical form in computers. It is a logical decimal and its position is assumed by the manufacturers. In our case, the logical decimal point is assumed to be at the leftmost position of a number. The exponent part will then indicate the position of the actual decimal with respect to this assumed dot. In our example, the exponent + 4 indicates that the actual position of the decimal point lies four decimal positions to the right of the logical decimal.
Thus, a real number, in floating point representation is expressed as follows:
N = MxRe
The mantissa M and the exponent e are physically present in a register of a computer. But, the radix R and the radix-point (decimal or binary point) are not indicated in the register. These are assumed things which are taken into account by the electronic cir¬cuitry which makes computation and manipulation.
The decimal number 0.005623 (= 0.5623 x 10’2) can be represented in floating point representation as follows:

Normalized Floating-Point Numbers
A normalized number is the number in which the most significant digit of the mantissa part is non-zero. For example, 8.9456 x 109 is a normalizsed number but 0.05677 x 10-7 is not a normalized number. Similarly, in case of binary numbers 0.0011100 x 2-7 and
0. 00001 x 24 are non-normalized numbers. The binary numbers 0.100110 x 28 and 0.11001011100 x 2-5 are normalized numbers. In some computers only normalized num-bers are stored. The mantissa part is shifted left till its most significant digit becomes non-zero and the exponent part is then adjusted accordingly.

For example a non-normalized number 0.0011100 x 2-7 can be shifted left 2 places and the resulting normalized number will be 0.11100 x 2-9.

Example 16
Represent 1101011 in the floating point representation using 32-bit word length.
Assume that 24 bits represent mantissa and 8 bits represent exponent.
Solution
1101011 = 0.1101011 x27
mantissa = 0.1101011, exponent = 7 or (111).
8 bits are used to represent exponent part. Hence exponent = 00000111. The left most bit,
i.e., most significant bit is 0 because exponent is positive.
Since mantissa is positive, the sign bit will be zero. As, 24 bits are used to represent mantissa, hence mantissa = 0 000000000000000 01101011.
The 32-bit representation of the given binary number 1101011 is as follows:

BINARY ARITHMETIC OPERATIONS
We all are very familiar with the Decimal Number System containing 10 digits namely 0,1,2,…., 9. But a computer does not understands this number system. What it operates on is 0 and 1, also called Binary’ Number System. We can easily perform all the arithmetic operations like addition, subtraction, multiplication, division, etc., on decimal numbers using pen and paper. As computer stores information in binary numbers, therefore, all arithmetic operations need to be performed using binary numbers. The designer of a computer must implement such operations on binary numbers through hardware or software, but the results should be the same as we would expect when addition, sub-traction, etc., are done on decimal numbers.
In this Chapter, we shall learn how the various arithmetic operations, such as addition, subtraction, etc., are performed on binary numbers.

Following rules apply when adding two numbers in binary form:
(a) 0 + 0 = 0
(b) 0 + 1 = 1
(c) 1 + 0 = 1
(d) 1 + 1 = 0 and a Carry 1

Example 17
Solution

Example 18
Solution

Example 19
Solution

Subtraction using 2s Complement
We know that 10-8 can be written as 10+(-8). The same applies to binary numbers also. This-is easy because using this method, subtraction can be implemented using the same method as that for addition.
Negative numbers are stored as 2s complement form in most digital computers. 2s com-plement of a number is obtained by computing Is complement and adding 1 to it. Is complement of a binary number is obtained by changing each 0 to a 1 and each 1 to a 0.

How to do Subtraction for Binary Numbers?
1. Compute Is complement of minuend (i.e., the number that is to be subtracted).
2. Compute its 2s complement which is Is complement + 1.
3. Add this value with the subtrahend (i.e., the number from which the minuend is to
subtracted).
4. Ignore if there is any carry.

Example 20
Subtract 0010 (i.e., decimal 2) from 0110 (i.e., decimal 6).
Solution
We need to perform 6-2 or we can say (6 + (-2))
(a) +2 is 0010. Therefore we represent -2 in its 2s complement form.
(b) Is complement of 0010 = 1101. Therefore, the 2s complement = 1101 + 0001 = 1110. Therefore -2 is represented in 2s complement form as 11110.
(c) Add -2 with 6 i.e. 0 0110 + 1 1110 = 1 0 0100.
(d) Here there is a carry 1. The carry is neglected in the 2s complement method. Hence the result is 0100 or decimal 4.

Example 21
Subtract 6 from 2. The number 6 is larger than 2.
Solution
(a) 6 is 0110. Therefore we show -6 in the 2s complement form.
(b) 1’s complement of 6 = 1001. And the 2s complement of 6 = 1001 + 0001 = 1010. Hence we will represent -6 in 2s complement form as 1 1010. Here, 1 at the left most position is for the negative sign placed before 6 i.e. -6.
(c) Add 2 with (-6) i.e. 0 0010 + 1 1010 = 1 1100.
(d) The result obtained has bit 1 at the most significant place. Therefore, the result is a negative number and it is stored in 2s complement form. So we compute 2s complement of 1100 and we get 0100 which is decimal 4. So the result is negative 4 or -4.

Example 22
Solution
(a) Both -2 and -12 will be represented in computer memory in their 2s complement form because both are negative numbers.
(b) 12 is 1100. Is complement of 12 = 0011, 2s complement = 0011 + 0001 = 0100. Hence -12 will be represented as 10100. Here, leftmost 1 is to represent the neg-ative sign before 12 i.e., -12.
(d) 2 is 0010. Is complement of 2 = 1101,2s complement = 1101 + 0001 = 1110. Hence -2 will be represented as 1 1110. Once again, the leftmost 1 is to represent the negative sign before 2 i.e., -2.
(e) Add-2 with-12 i.e., 10100 + 11110 = 10010.
(f) The result obtained has bit 1 at the most significant place. Therefore, result is a negative number and the result would be found by taking 2s complement of 0010 which is 1101 + 1 = 1110 i.e. decimal 14. Hence, result = -14.

INTERNAL STORAGE AND ENCODING OF CHARACTERS
All digital computers have to handle alphabets and special characters besides numbers. In the older types of computers, the total number of characters represented were very few and only six bits were used to code a character. In recent machines, the number of characters has increased. Besides capital and small English alphabets, several mathe¬matical symbols like >, <, a, pi, etc., have been introduced. This required the introduction of new codes that used 7 or 8-bit for coding characters.

ASCII Code
ASCII (pronounced “askee”) (American Standard Code for Information Interchange) is the most common alphanumeric code used to represent characters like A, B, C, etc. Alpha-numeric code is for letters, numbers and other symbols. Earlier there used to be many alphanumeric codes which lead to all kinds of confusion. But now the industry has settled on the ASCII code. This code allows manufacturers to standardise computer hardware, such as keyboards, printers, and video displays.
ASCII is of two types : ASCII-7 and ASCII-8. ASCII-7 is a 7-bit code that allows 128 (27) different characters. The first 3 bits are used as zone bits and the last 4 bits indicate the digit. Microcomputers using 8-bit byte (group of 8 bits for one byte) use the 7-bit ASCII by leaving the leftmost bit of each byte as a zero. Table 3.4 shows the alphabetic and numeric characters in ASCII-7 bit notation.

ASCII-8 is an extended version of ASCII-7. It is an 8-bit code that allows 256 (28) differ¬ent characters rather than 128. The additional bit is added to the zone bits. Table 3.4 shows the alphabetic and numeric characters in ASCII-8 bit notation. Observe that other than the zone-value differences, ASCII-7 and ASCII-8 are identical. ASCII also uses hex¬adecimal as its four-to-one shortcut notation for memory dump. Tables 3.4 and 3.5 also show the hexadecimal equivalents of the ASCII notations.

Example 23
Write the binary coding for the word BOY in ASCII-7. How many bytes are required for this representation?
Solution

As each character in ASCII-7 requires one byte for its representation and since there are 3 characters in the word BOY, so 3 bytes will be required for this representation.

Example 24
Write the hexadecimal coding for the word GIRL in ASCII-7. How many bytes are required for this representation?
Table 3.4 Numeric and Alphabetic Characters in ASCII-7 BIT Notation along with their Hexadecimal Equivalents.

Table 3.5 Alphabets in ASCII-8 Bit Notation their Hexadecimal Equivalents

Solution

Example 25
Write the binary coding for the word SKY in ASCII-8. How many bytes are required for this representation?
Solution

As each character in ASCII-8 requires one byte for its representation and since there are 3 characters in the word SKY, so 3 bytes will be required for this representation

Example 26
Write the hexadecimal coding for the word STAR in ASCII-8. How many bytes are required for this representation?
Solution
S = B3 in ASCII-8 hexadecimal notation
T = B4 in ASCII-8 hexadecimal notation
A = A1 in ASCII-8 hexadecimal notation
R = B2 in ASCII-8 hexadecimal notation
Hence the hexadecimal coding for the word STAR in ASCII-8 will be:
B3 B4 A1 B2
S T A R
As each character in ASCII-8 requires one byte for its representation and since there are 4 characters in the word STAR, so 4 bytes will be required for this representation.

ISCII (Indian Script Code for Information Interchange)
ASCII code is for English letters. But ISCII is used for Indian languages. ISCII has been created by the Indian Standards Organization (ISO). The Indian Standard uses the 7-bit code for English letters as in ASCII. It uses 8-bit codes extensions for Indian scripts. Thus, we can use English language with Indian languages on the same keyboard. Thus, a common keyboard is used for both English and Indian languages. The standard English keyboard is maintained for English alphabets. An overlay is designed on this keyboard for Indian scripts.

Unicode
Unicode is a fully international alphanumeric code which can represent all of the char¬acters found in human languages. It can represent Katakana, Cyrillic, Latin, Greek, Ara¬bic, Hebrew, Hangul and many more characters. Unlike ASCII code, Unicode requires 16 bits for character representation. Hence Unicode provides for universal portability. The disadvantage with Unicode is that it is inefficient for languages, such as English, French, German, Spanish, etc., which can easily be represented using 8 bits.

SOLVED EXERCISE

Question 1.
Convert the binary number 11001 into its decimal equivalent.
Binary number in the spread form =11001
Bit position from right hand side = 4th 3rd 2nd 1st 0th
11001 (Binary) = 1 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 1 x 2°
=16 + 8 + 0 + 0+1
= 25 (Decimal)

Question 2.
Convert the hexadecimal number 2B6D into its decimal equivalent.
2B6D = 2 x 163+B x 162+6 x 161+D x 16°
= 2×4096+11×256+6×16+13×1
= 8192 + 2816 + 96 + 13
= 11117(decimal)

Question 3.
Convert the hexadecimal number 3DE to its equivalent octal number.
The hexadecimal number 3DE is first converted to its binary equivalent
3DE16 = (0011) (1101) (1110)
= (001111011110)2
Now the above binary equivalent is divided into groups of 3 bits to obtain its octal equivalent
(001111011110)2 = (001)(111)(011)(110)
= 1736 (octal)

Question 4.
Convert the real binary number 1011.1011 to its equivalent octal number
In the integer part of the real binary number 1011.1011 the group of 3 bits is formed from right to left. In the binary fraction the group of 3 bits is formed from left to right.
(1011.1011)2 = (1) (011). (101) (1)
=(001)(011).(101)(100)
=13.54 (octal)

Question 5.
Convert the real octal number 46.57 to its equivalent hexadecimal number.
Converting 46.57 (octal) first to its binary equivalent we get,
46.57 = (100) (110). (101) (111)
= (100110.101111)2
Now forming the groups of 4 binary bits to obtain its hexadecimal equivalent we have,
100110.101111 =(10)(0110).(1011)(11)
=(0010)(0110).(1011)(1100)

Question 6.
Represent a binary number 1101011 in floating-point representation using 32-bit word length. 24 bits represent mantissa and 8 bits represent exponent.
The binary number
1101011 = 0.1101011 x27
For this number, mantissa = 0.1101011
The exponent = 7
In the biased representation, exponent is added with +128. Hence, the modified exponent = 7 + 128 = 135
135 = 10000111
Since mantissa is positive, it’s sign bit will be 0.

Question 7.
Convert the decimal fraction 0.5185 to an equivalent binary fraction

In this example it is shown that the fraction is not becoming zero, and the process will continue further. For such a case an approximation is made. Here we have taken the result up to 6 binary bits. Hence,
(0.5185)10 = (100001)2

Question 8.
Write short note on ISCII.
ASCII code is for English letters. But ISCII is used for Indian languages. ISCII has been created by the Indian Standards Organisation (ISO). The Indian Standard uses the 7-bit code for English letters as in ASCII. It uses 8-bit codes extensions for Indian scripts. Thus, we can use English language with Indian languages on the same key¬board. Thus, a common keyboard is used for both English and Indian languages. The standard English keyboard is maintained for English alphabets. An overlay is designed on this keyboard for Indian scripts.

Question 9.
Convert the real hexadecimal number 5B.3A to its equivalent octal number.
5B.3A16 = (0101) (1011).(0011)(1010)2
= 01011011.001110102
Now forming the groups of 3 binary bits to obtain its octal equivalent we have,
01011011.001110102 = (01)(011)(011).(001)(110)(10)2
= (001)(011)(011).(001)(110)(100)2
= 133.1648

Question 10.
Convert the real octal number 46.57 to its equivalent hexadecimal number
46.578 = (100)(110).(101)(111)2
= 100110.1011112
Now forming the groups of 4 binary bits to obtain its hexadecimal equivalent we have,
100110.1011U2
= (10)(0110).(1011)(110)2
= (0010)(0110).(1011)(1100)2
= 26.BC16

Question 11.
Obtain the Is and 2s complement of the following eight bit binary numbers:
(a) 10101110
(b) 10000001
(a) 1’s complement of 10101110=01010001
2s complement = 01010001+00000001 = 01010010
(b) 1’s complement of 10000001 = 01111110
2s complement = 01111110+00000001 = 01111111

Question 12.
Perform the following:
(a) Convert (1100110110001)2 to decimal.
(b) Convert (2057)10 to binary.
(a) 1100110110001 = 1×212+1×211+0x210+x29+1×28+1×27+0x26+1×25+1×24+0x23+0x22+0x21+1×2°
= 4096 + 2048 + 0 + 0 + 256 + 128 + 0 + 32 + 16 + 0 + 0 + 0 + 1
= (6577)10

Question 13.
(a) What is hexadecimal number system?
The hexadecimal number system has the radix (base) as 16. Its digits range from 0 to 9 and A to F. Thus in a hexadecimal number system, decimal num¬ber 10 is represented by A, 11 by B, 12 by C, 13 by D, 14 by E and 15 by F. The decimal number 16 is represented as 10 and 17 by 11 in hexadecimal number system.
A hexadecimal digit is represented by four binary bits. For instance, the num¬ber 5 is represented by 0101 hexadecimal equivalent. The digit A of hexadecimal is 1010 in 4-bit binary representation.

Question 14.
Convert (7305)8 to Binary.
To convert (7305)8 to binary number follow the steps given below: Write binary equivalent of each digit
7 = 1111, 3=011, 0=000,5=101
The binary number will be :
(111 011 000 101)2

Question 15.
Convert (14E)16 and (6DC)16 to its binary equivalent.
(14E)16 =(?)2
1 = 0001,4 = 0100, E= 14=1110 (14E)16 =(000101001110)2
(6DC)16 = (?)2
6 = 0110, D = 13 = 1101, C = 12 = 1100 (6DC)16 = (011011011100)2

Question 16.
Express the following binary fractions to their decimal equivalents:
(0.111)2 (11011.101)2
(0.111)2
=1×2-1 + 1×2-2 + 1×2-3
=1/2 +1/4+ 1/8
=0.5 + 0.25 + 0.125
=(0.875)10
(11011.101)2
=1×24 + 1×23 + 0x22 + 1×21 + 1×2° + 1×2-1 + 0x2-2 + 1×2-3
=16 + 8 + 0 + 2 + 1 + 1/2 + 0 + 1/8
= 27+1/2 + 1/8 -> 27 + 0.5 + 0.125
= (27.625)2

Question 17. Multiple choice questions

Question 1.
The binary number system has a base
2
4
8
16

2

Question 2.
The widely used code in data communication is
8-bit ASCII
EBCDIC
7-bit ASCII
None of the above

8-bit ASCII

Question 3.
Octal equivalent of the pure binary bits (1001101)2 is:
464
715
125
115

115

Question 4.
What is the Hexa decimal value of decimal number 15?
F
1
0
E

F

Question 5.
The octal equivalent of 111010 is:
71
72
73
None of the above 