Chapter 3
Chapter 3
Data Representation
A computer is a machine that process data, and understand the nature of that data. Data can be
found in different forms like as a number, text, images audio & video. Most microprocessors &
minicomputers are normally byte oriented with word length 8 bits, 16 bits 32 bits & 64 bits.
Number system
A number system defines a set of values used to represent quantity. Today the most common
number system in use is Arabic system. The number systems can be categorized in to two broad
categories: Positional number systems & Non-positional number systems.
Non-Positional number systems: - is a method of counting on fingers. It was very difficult to
perform arithmetic with such a number system, as it had no symbol for zero.
Positional number systems: - the value of each digit in a number is defined not only by the symbol
but also by the symbol’s position. They have a base or radix.
Base (or radix): - tells the number of symbols used in the system. Modern computers use the radix
2 because they recognize only two symbols, which are represented in digital circuits as 0s and 1s.
The base of a number system is indicated by a subscript (decimal number) and this will be followed
by the value of the number.
For example (7592) 10 is of base 10 number system.
(1010) 2 is of base 2 number system.
Note: For a computer, everything is a number whether it may be numbers, alphabets, punctuation
marks etc.
- Eventually, the number systems that can are generally used by the computers are:
Decimal system
Binary system
Octal system
Hexadecimal system
Page 1
Number system Radix value Set of Digits Example
Page 2
Octal Number System
Octal number system
Page 3
Hexadecimal Number System
Hexadecimal number system has the base (radix) 16. Each hexadecimal number represents a power
of 16. To represent the decimal numbers, this system uses 0-9 numbers and A to F characters to
represent 10 to 15, respectively.
Decimal Hex Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Page 4
Conversion between Number Systems
1. Conversion of Decimal to Binary: Follow the following steps to convert decimals in to binary.
1. Begin by dividing the decimal number by 2 (the base of binary number).
2. Note the remainder separately as the right most digit of the binary equivalent.
3. Continually repeat the process of dividing by 2 until the quotient is zero.
4. Finally, when no more division can occur, write down the remainders in reverse order (last
remainder written first).
Eg. Determine the binary equivalent of (36) 10
2 36 Remainder
Least Significant Bit (LSB)
2 18 0
2 9 0
2 4 1
2 2 0
2 1 0
0 1 Most Significant Bit (MSB)
Taking the remainders in reverse order, we have 100100. Thus (36) 10 = (100100) 2.
2. Conversion of Binary to Decimal: In this case, each digit of the binary number is multiplied by its
weighted position and each of the weighted values is added together to get the decimal number.
Eg determine the decimal equivalent of (11010) 2
(11010) 2 = (1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (0 x 20)
= 16 + 8 + 0 + 2 + 0
= (26) 10
3. Conversion of Binary fractions to Decimal: here we use the negative exponents, to denote the
negative powers of two.
Eg. Determine the decimal equivalent of (0.01101) 2
(0.01101) 2 = (0 x 2-1) + (1 x 2-2) + (1 x 2-3) + (0 x 2-4) + (1 x 2-5)
= 0 + ¼ + 1/8 + 0 + 1/32
= 0 + 0.25 + 0.125 + 0 + 0.03125
= (0.40625) 10
Page 5
4. Conversion of Decimal to Octal: Here the same procedure is adopted as in decimal to binary
conversion but the decimal number is divided by 8 (the base of the octal system).
Eg. Determine the octal equivalent of (359) 10
So (359) 10 = (547)8
5. Conversion of Decimal fraction to Octal fractions: The steps we have to follow in this case
are:-
1. Multiply the decimal fraction by 8 (the base of the octal system).
2. If the whole number is generated, record the whole number, otherwise place 0.
3. Repeat the above 1st and 2nd steps with the decimal fractions until it becomes.
4. Finally, when no more multiplication can occur, write down the remainders in the
downward direction.
5. In this whole conversion, the first carry produced is the MSB while the last carry is the
LSB.
Eg. Determine the octal equivalent of (0.3125) 10.
0.3125 x 8 = 2.5 2
0.5 x 8 =4.0 4
So, (0.3125) 10 = (0.24) 8
Note: In some circumstances of changing the decimal fraction to octal fractions the conversion may
not end. In such cases you have to take the approximate of 8 bits.
6. Conversion of octal to Decimal: Here each digit of octal number is multiplied by its weighted
position, and each of the weighted values are added together to get the decimal number.
Eg. Determine the decimal equivalent of (456)8.
(456) 8 = (4 x 82) + (5 x 81) + (6 x 80)
= 256 + 40 + 6
= (302) 10
Page 6
7. Conversion of Octal fractions to Decimal fractions: Steps followed here are:
1. Write the weight value of each bit of the octal fractional number.
2. Multiply the weighted position with the respective bit of the octal fractional number.
3. Add all the weighted values to get the decimal number.
Eg. Determine the decimal equivalent of (237.04) 8.
(237.04) 8 = (2 x 82) + (3 x 81) + (7 x 80) + (0 x 8-1) + (4 x 8-2)
= (2 x 64) + (3 x 8) + (7 x 1) + (0) + (4 x 1/64)
= 128 + 24 + 7 + 0 + 0.0625
= (159.0625) 10
Page 7
10. Conversion of Decimal to Hexadecimal: To convert a decimal number into its
hexadecimal equivalent, the same procedure is adopted as decimal to binary but the decimal
number is divided by 16 (the base of the hexadecimal number system).
E.g. determine the hexadecimal equivalent of (5112) 10.
16 5112 Remaineder
Least Significant Bit (LSB)
16 319 8=8
16 19 15=F
16 1 3=3
16 0 1=1 Most Significant Bit (MSB)
Page 8
Que. Determine the decimal equivalent of (8AFE2B) 16.
13. Conversion of hexadecimal fractions to Decimal fractions: steps
1. Write the weighted value of each bit of the hexadecimal fractional number.
2. Multiply the weighted position with the respective bit of the hexadecimal fractional
number.
3. Add all the weighted values to get the decimal number.
E.g. determine the decimal equivalent of (A.23) 16
(A.23) 16 = (A x 160) + (2 x 16-1) + (3 x 16-2)
=10 + 0.125 + 0.01171875
= 10.13671875
Page 9
Decimal to Other Base System
Step 1- Divide the decimal number to be converted the value of the new base.
Step 2-Devide the Quotient until the quotient became 0
Step 3-Store or Save the remainder starting from bottom to top
The last remainder thus obtained will be the Most Significant Digit (MSD) of the new base number.
Example Decimal Number: 2910
Calculating Binary Equivalent
Step Operation Result Remainder
Step1 29/2 14 1
Step2 14/2 7 0
Step3 7/2 3 1
Step4 3/2 1 1
Step5 ½ 0 1
As mentioned in Step2 and 4, the remainders have to be arranged in the reverse order so that the
first remainder becomes the Least Significant Digit (LSD) and the last remainder becomes the Most
Significant Digit (MSD).
Decimal Number: 29/210=Binary Number: 111012.
Other Base System to Decimal
Step1 -Determine the column (positional) value of each digit (this depends on the position of the
digit and the base of the number system).
Step2 –Multiplied the obtained column values (in step1) by the digits in the corresponding
columns.
Step3 –Sum the products calculated in step2. The total is the equivalent value in decimal.
Example Binary number: 101012
Calculating decimal equivalent –
Step Binary Decimal number
number
Step1 101012 ((1*24) +(0*23) +(1*22) +(0*21) +(1*20))10
Step2 101012 (16+0+4+0+1)10
Step3 101012 2110
Binary Number: 111012=Decimal Number: 2910
Other Base System to Non-Decimal
Step1 –Convert the original number in to decimal number (base 10).
Step2 –Convert the decimal number so obtained to the new base number.
Example Octal number: 258
Calculating Binary Equivalent
Step1 –Convert to Decimal
Step Octal Number Decimal Number
Step1 258 ((2*81) +(5*80))10
Step2 258 (16+5)10
Step3 258 2110
Octal Number: 258=Decimal Number: 2110
Page 10
Step2 –Convert Decimal to Binary
Step Operation Result Remainder
Step1 21/2 10 1
Step2 10/2 5 0
Step3 5/2 2 1
Step4 2/2 1 0
Step5 ½ 0 1
Decimal Number: 2110=Binary Number: 101012
Shortcut Method-Binary to Octal
Step1-Devide the binary digits into groups of three (starting from the right).
Step2-Convert each group of three binary digits to one octal digit.
Example Binary Number: 101012
Calculating Octal Equivalent
Step Binary Number Octal Number
Step1 101012 010 101
Step2 101012 28 58
Step3 101012 258
Binary Number: 101012=Octal Number: 258
Shortcut Method- Octal to Binary
Step1 Convert each octal digit to a 3-digit binary number (the octal digits may be treated as decimal
for this conversion).
Step2 Combine all the resulting binary groups (of 3 digits each)into a single binary number.
Example Octal Number: 258
Calculating Binary Equivalent
Step Octal Number Binary Number
Step1 258 210 510
Step2 258 0102 1012
Step3 258 0101012
Octal Number: 258=Binary Number: 101012
Shortcut Method-Binary to Hexadecimal
Step1 Divide the binary digits into groups of four (starting from the right).
Step2 Convert each group of four binary digits to one hexadecimal symbol.
Example Binary Number: 101012
Calculating Octal Equivalent
Step Binary Number Hexadecimal Number
Step1 101012 0001 0101
Step2 101012 116 516
Step3 101012 1516
Binary Number: 101012=Hexadecimal Number: 1516
Page 11
Shortcut Method-Hexadecimal to Binary
Step1 Convert each Hexadecimal digit to a 4-digit binary number (the hexadecimal digits may be
treated as decimal for this conversion).
Step2 Combine all the resulting binary groups (of 4 digits each) into a single binary number.
Example Hexadecimal Number: 1516
Calculating Binary Equivalent
Step Hexadecimal Number Binary Number
Step1 1516 110 510
Step2 1516 00012 01012
Step3 1516 000101012
Page 12
Binary Subtraction: Subtraction is generally simple in comparison to addition since only two
numbers are involved. In binary subtraction the problem ‘borrow’ is similar to that in decimal. If the
subtrahend bit is equal to or smaller than the minuend bit, then perform subtraction, otherwise
borrow one from its left most neighbor. Binary subtractions follow four rules for the operation.
Input Output
X Y Difference (D) Borrow (B)
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
0 10
1 1 0 1 1 3
- 1 0 1 1 - 1 1
0 0 1 0 0 2
Thus the binary difference is (0010) 2.
2. Octal Arithmetic: The essential arithmetic operations of the octal number system are:
Addition
Subtraction
i. Octal Addition: Addition of the octal number is carried out in the same way as the
decimal addition is performed. The steps are given below:
1. First, add the two digits of the unit column of the octal number in decimal.
2. This process is repeated for each larger significant digit of the octal number.
3. During the process of addition, if the sum is less than or equal to 7, then it can
be directly written as an octal digit.
4. If the sum is greater than 7, then subtract 8 from that particular digit and carry 1
to the next digit position
Page 13
E.g. Add the octal numbers 26 and 17.
1 (carry)
2 6
+ 1 7
4 13
- 8
4 5 Thus the octal sum is (45) 8.
Octal Subtraction: In the octal subtraction, the method, which we have adopted, is similar to that
of binary subtraction method. The only difference lies in the carry part. During octal subtraction
instead of 1, we will borrow 8 and the rest of steps are similar to that of binary subtraction.
E.g. Subtract (667) 8 from (770) 8.
8+6=14
6 6 8 (Borrow)
7 7 0
- 6 6 7
1 0 1 Thus, the difference is (101) 8.
Hexadecimal Arithmetic: Hexadecimal number system is extensively used in the memories of the
computer system and in the computer instructions. The basic arithmetic operations that are to be
performed are listed below:
Addition
Subtraction
Hexadecimal Addition: The addition operation performed with the hexadecimal numbers is
analogous to the decimal addition except with a few differences that are discussed in the following
steps:
1. First add the unit column of the hexadecimal digits in decimal.
2. This process is repeated for each larger significant digit of the hexadecimal
number.
3. During the process of addition, observe if the sum is 15 or less, then it can be
directly expressed as hexadecimal digit.
Page 14
4. If the sum is greater than 15, then subtract 16 from that particular digit and carry
1 to the next digit position.
E.g. Add the hexadecimal numbers (A27E9) 16 and (6FB43) 16.
1 1 1 1 1 1
A 2 7 E 9
+ 6 F B 4 3
1 17 18 19 18 12
-16 -16 -16 -16 -
1 1 2 3 2 12(=C) Thus the hexadecimal sum is (11232C) 16
Hexadecimal Subtraction: The hexadecimal subtraction is based on the same principles as of
binary subtraction. In this subtraction, 16 will be used as borrow instead of 1. The rest of steps are
similar to the binary subtraction.
E.g. Subtract (75) 16 from (527) 16.
4 16+2=18 (Borrow)
5 2 7
- 7 5
4 11 2
4 B 2 (Hex form) Thus the hexadecimal difference is (4B2) 16.
ii. A d d five 0’s to make a total of N (8) bits 00000111. Therefore, the number is stored in
the memory location.
Page 15