LATEST UPDATES

Search This Blog

Chapter2. Data Representation

Friday, August 30, 2013

Chapter2. Data Representation
Representation of data is classified in to two, Internal form and external form. The characters and numbers fed to a computer, and the output from the computer, must be in a form, which is usable by people. For this purpose natural language symbols and the decimal digits are used for this purpose. Such form of data is known as the external form of data which is understandable for the users.
On the other hand, the representation of data inside a computer must match the technology used by the computer to store and process data. Computer being an electronic device, the most suitable internal form of data uses binary number system, which uses only two symbols, 1 and 0. These symbols can represent two states of an electronic device; that is, 1 represents ON and 0 represents OFF this representation is called internal form.
Number Systems
          In a positional number system, there are only a few symbols called digits, and these symbols represent different values depending on the position they occupy in the number. The value of each digit in such a number is determined by three considerations:
          i)       The digit itself.
          ii)       The position of the digit in the number.
          iii)      The base of the number system (where base is defined as the total           numbers of digits available in the number system).
Number systems are classified into four, Decimal, Binary, Octal and Hexadecimal number system.
Decimal Number System
          The base of decimal system is 10 because it uses 10 digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. The positional values of the digits are the in the powers of 10. A digit having highest weight is called Most Significant Bit (MSB) and the digit having the lowest is called Least Significant Bit (LSB).
Consider the number 1523. Here 3 is the LSB which is having the positional values 100, 2 is having the positional value 101, 5 is having 102, and 1 is the MSB with the positional value 103.
          In decimal number system, the positional values of the digits after decimal point start from 10-1.  For example, consider the number 15.23. The pictorial representation of this number is as follows:
Positional Values
101
100

10-1
10-2
Weight
1
5
.
2
3

MSB

LSB
Binary Number System
          The electronic circuits have only two voltage levels ‘on’ and ‘off’. So the electronic devices use binary number system to represent everything since the binary number system has only two digits 0 and 1. The ‘OFF’ position is represented by the digit 0 and ‘ON’ position by the digit 1.
          Computer stores everything in its memory. The memory is designed to hold binary values only. The base of binary system is 2, because it uses only two digits 0 and 1. The binary digit it is also called ‘bit’. Each memory cell can store one bit. Here the positional value of each bit is in the power of 2.
          Consider the binary number 1011.101. The positional values of the digits are shown in the following figure.
Positional Values
23
22
21
20

2-1
2-2
2-3
Weight
1
0
1
1
.
1
0
1

MSB

LSB
Octal Number System
          Octal number system uses eight digits 0,1,2,3,4,5,6 and 7 and so its base is 8. For example, the digits of the octal number 762.240 are assigned with positional as follows.
Positional Values
82
81
80

8-1
8-2
8-3
Weight
7
6
2
.
2
4
0

MSB

LSB
Hexadecimal Number System
          The base of the hexadecimal number system is 16 and the system has 16 digits (or symbols) 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. Note that the digit or symbol after are 9 is A and it is equivalent to the decimal number 10 Similarly, B is equivalent to 11; C is equivalent to 12 etc. Consider the hexadecimal number 7AF.6C1. Its digits have positional values as follows.
Positional Values
162
161
160

16-1
16-2
16-3
Weight
7
A
F
.
6
C
1

MSB

LSB
Number Conversions
Conversion from Decimal to Binary, Octal and Hexadecimal
Example1: Conversion of decimal number 25 into binary.
2
25
Reminders
2
12
1
2
6
0
2
3
0
2
1
1

0
1
Therefore, (25)10 = (11001)2
Example2: Conversion of decimal number 194 into octal number.
8
194
Reminders
8
24
2
8
3
0

0
3
Therefore, (194)10 = (302)8
Example3: Conversion of decimal number 781 into hexadecimal number
16
781
Reminders
16
48
13 (D)
16
3
0

0
3
Therefore, (781)10 = (30D)16
Converting Decimal Fractions to a New Base
Example1: Convert 0.375 into binary form.
                                      Integer part of the result
0.375 x 2 = 0.75                              0
0.75 x 2 = 1.5                                  1
0.5 x 2 = 1                                        1
Therefore, (0.375)10 = (.011)2
Example2: Conversion of decimal number 42.22 into binary
Stage1: Conversion of 42 into binary
2
42
Reminders
2
21
0
2
10
1
2
5
0
2
2
1
2
1
0

0
1
Thus 42 = (101010)2
Stage: 2 Conversion of 0.22 into binary
0.22x2=0.44                 0
0.44x2=0.88                 0
0.88x2=1.76                 1
0.76x2=1.52                 1
0.52x2=1.04                 1
Thus, 0.22= (.00111)2
Therefore, 42.22= (101010.00111)2
Example3: Conversion of decimal number 17.375 into octal number
Stage1: Converting the integer part 17
8
17
Reminders
8
2
1

0
2
Thus, 17=(21)8
Stage2: Converting the fractional part .375
0.375x8=3.00               3
Thus, .375=(3)8
Therefore, 17.375=(21.3)8
Example4: Conversion of decimal number 28.03125 into hexadecimal number
Stage1: Converting the integer part 28
16
28
Reminders
16
1
12 (C)

0
1
Thus, 28=(1C)16
Stage2: Converting the fractional part .03125
0.03125x16=0.5                    0
0.5x16=8.0                                      8
Therefore, 28.03125=(1C.08)16
Conversion from Binary, Octal, Hexadecimal to Decimal
(Sum of the products Method)
Example1: Conversion of binary number 1011 into decimal form
1x23+0x22+1x21+1x20
          8 + 0 + 2 + 1 = 11
          Thus, (1011)2 = (11)10
Example2: Conversion of binary number 11011.0101 into decimal form
(11011.0101)2 = 1x24+1x23+1x22+1x21+1x20+0x2-1+1x2-2+0x2-3+1x2-4
=16+8+0+2+1+0+1x1/4+0+1x1/16
=27+0.25+0.125
=(27.375)10
Example3: Conversion of octal number 351.16 into decimal form
(351.16)8=3x82+5x81+1x80+1x8-1+6x8-2
=192+40+1+1/8+6x1/64
=233+0.125+0.09375
= (233.21875)10
Example4: Conversion of hexadecimal number 9AF.B into decimal form.
(9AF.B) 16=9x162+10x161+15x160+11x16-1
=9x256+10x16+15x1+11x1/16
=2304+160+15+0.688
= (2479.688)10
Shortcut Conversion from Binary to Octal (Shortcut method)
Example1: Conversion of binary number 10101.11 into octal form.
Step1: Divide the binary digits into groups of 3.
Step2: Convert each group into one digit of octal (uses binary-to- decimal conversion or refers the table).
 (Zero (0) is to be supplied to the left integer part and to the right of decimal part to make it group of 3 bits)
25
24
23
22
21
20
32
16
8
4
2
1

                    
The digits in the given number(3digit group)   
010
101
.
110
Octal equivalents of the group
2
5
.
6

Hence, (10101.11)2 = (25.6)8
Conversion from Octal to Binary (Shortcut Method)
Example1: Conversion of octal number 712.62 into binary form
          The given octal number   
7
 1
  2
.
  6
  2
Binary equivalents of the digits
111
001
010
.
110
010
Therefore, (712.62)8 = (111001010.110010)2
Conversion from Binary to Hexadecimal (Shortcut Method)
Example1: Conversion of binary number 1100010.101 into hexadecimal form
(Zero (0) is to be supplied to the left integer part and to the right of decimal part to make it group of 4 bits).
Given Binary Number
0110
0010
.
1010
Equivalent hex digit
6
2
.
A
          Therefore, (1100010.101)2 = (62.A) 16
Conversion from Hexadecimal to Binary (Shortcut Method)
Example1:          Conversion of hexadecimal number 971.AB into binary form
         
Given Hexadecimal Number:
   9
  7
  1
.
  A
  B
Binary Equivalents
1001
0111
0001
.
1010
1011
Therefore, (971.AB) 16 = (100101110001.10101011)2
Conversion from Octal to Hexadecimal (Shortcut Method)
Step1: Convert the given octal number into binary.
Step2: Convert the binary number obtained in step 1 into hexadecimal number.
Example1: Convert (67.53)8 into hexadecimal.
The given octal number   
6
7
.
5
3
Binary Equivalents
110
111
.
101
011
Group them in to Four digits
0011
0111
.
1010
1100
Hexadecimal Number
3
7
.
A
C
Thus, (67.53)8=(37.AC)16
Conversion from Hexadecimal to Octal (Shortcut Method)
Step1: Convert the given hexadecimal number into binary.
Step2: Convert the binary number obtained in Step 1 into octal number.
Example1: Convert (AC.3D)16 into octal number
The given Hexadecimal number   
A
C
.
3
D
Binary Equivalents
1010
1100
.
0101
1101
Group them in to Three digits
010
101
100
.
010
111
010
Hexadecimal Number
2
3
4
.
2
7
2

Thus, (AC.3D)16=(234.272)8
Binary Addition
The complete table for binary addition is as follows:
          0 + 0 = 0
          0 + 1 = 1
          1 + 0 = 1
          1 + 1 = 0, Carry 1
          1 + 1 + 1 = 1, carry 1
Example1: Add the binary numbers 10010 and 101.
Binary
10010 +
    101
10111
Example2: Add the binary numbers 10111 and 11001.
  10111 +
  11001
110000
Binary Subtraction
0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
0 - 1 = 1 with a borrow 1 from the next column
Example1: Subtract binary number 100 from 1101
1101 –
  100
1001
Example2: Subtract binary number 1110 from 10101
10101 –
  1110
00111
Binary Representation of Integers
          The integers are represented in memory by three different ways: i) One’s complement representation, ii) Two’s complement representation and iii) Sign and magnitude representation.
One’s Complement Representation
Example1: Represent the decimal number 17 in one’s complement binary form.
The number 17 is positive and so it is represented in its original binary form.
Therefore, (17)10 = (10001)2
Example2: Represent the decimal number -24 in one’s complement binary form.
          Binary form 24 is (11000)2
          Considering the word size to be 8, (24)10 = (00011000)2
          One’s complement of (00011000)2 = (11100111)2
(Here every 1 of the binary number is replaced by 0 and every 0 is replaced by 1 to get the one’s complement)
          Therefore, Binary form of - 24 in 1’s complement form is (11100111)2
Two’s Complement Representation
Example1: Represent the decimal number 20 in 2’s complement form.
          The number 20 being positive, it is represented in the original binary form.
          Therefore, (20)10 = (10100)2
Considering the word size to be 8 bits, (20)10 = (00010100)2
Example2: Represent the decimal number -21 in 2’s complement form.
          Binary of 21 = (10101)2
          Considering the word size to be 8, = (00010101)2
          1’s Complement of (00010101)2 = (11101010)2
          Hence 2’s Complement of (-21)10 = 11101010 +
                                                                                    1
                                                                      11101011
(Adding a 1 on the LSB of 1’s complement)
Thus, (-21)10 = (11101011)2
Sign and Magnitude Method
          In this method, a bit (MSB) allotted for storing the sign of the number. If the sign is positive, the bit will be 0, otherwise it will be 1. The remaining bits represent the magnitude (Value) of the numbers.
Example1: Represent the decimal number 23 in sign and magnitude form.
          Here the sign bit is set to zero, because the number is positive.
          (23)10 = (10111)2
          Considering the word size to be 8 bits, the above number is presented as,
          (00010111)2                                                      
Example2: Represent the decimal number -23 in sign and magnitude form.
          (10010111)2
Binary representation of real numbers
          They represented in memory by their exponent and mantissa. Here 10 bit is used for mantissa and 6 bit for exponent.
Example:
Mantissa
Exponent
0110001000
110111
Subtraction using 1’s and 2’s Complement Methods
Subtraction using 1’s complement method
It involves the following three steps:
Step 1: Find the complement of the number you are subtracting (subtrahend)
Step 2: Add this to the number from which you are taking away (minuend)
Step 3: If there is a carry of 1, add it to the sum to obtain the result. If there is no carry, re complement the sum and attach a negative sign to obtain the result.
Example: Subtract (0111000)from (1011100)using 1’s complement method.
          The minuend is,                             1011100 +
          1’s complement of 0111000 is,  1000111
          Adding,                                       10100011
          Taking the carry 1 to add,                     1
                                                                  0100100
          Therefore, 10111002 - 01110002 = 01001002
Subtraction using 2’s complement method
Example1: Subtract  the binary number 0111000 from 1011100 using 2’s complement method.
          The subtrahend is,               0111000
          1’s complement of it is,                1000111 +
          Adding 1 to it                                  1
          2’s Complement is              1001000
          The minuend is,                             1011100 +
          2’s Complement + Minuend               1001000
                                                                    0100100
Ignoring the carry (MSB) is the result.
          Thus, (1011100)2 – (0111000)2 = (0100100)2      
Representing Characters in Memory
          Alphanumeric codes are used as the intermediate code for the conversion from characters to their binary form. The alphanumeric code includes 25 upper case letters, 26 lower case letters, 10 numeric digits, 7 punctuation marks and the special characters such as +, /, # % * etc.
          ASCII (American standard code for information Interchange) is the most commonly used alphanumeric code. EBCDIC (Extended Binary Coded Decimal Interchange Code) is another alphanumeric code.
ASCII Codes
          ASCII is of two types: ASCII-7 and ASCII-8. The 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.
          ASCII-8 is an extended version of ASCII-7. It is an 8 bit code that allows 256 (28) different characters rather than 128.
Unicode
          Now a day’s most of the computers use a new code called Unicode and it defines an International Character Set. The Unicode can represent all of the characters found in all human languages. This becomes possible because Unicode uses 16 bits to represent a character. Many languages such as Latin, Greek, Arabic, Hebrew etc. have adopted this coding scheme.

No comments:

Post a Comment

 

Welcome Plus one ,How you rate IT Club SKHSS

Members

Contact Form

Name

Email *

Message *

Visitors Counter

Most Reading

SREEKRISHNA HIGHER SECONDARY SCHOOL- IT CLUB. Powered by Blogger.