Monday, September 13, 2010

DATA REPRESENTATION


DATA REPRESENTATION

CODING SCHEMES
To understand how a bit pattern can convey information, consider someone who wants to give a signal (or send a code) to another person, but has only a single light bulb at his disposal. How many different messages (codes) can he send? Two, one for light ON and the other for light OFF. What if he had two bulbs? At first thought one might say he can now send three signals corresponding to:
  1. both OFF;
  2. both ON;
  3. one ON.

This would be fine if he only wanted to send three signals. But what if he wanted to send four signals? Would he need another bulb? The answer is no, he can send four signals with two light bulbs, but the sender and receiver (of the signals) would have to come to an agreement concerning case (3), above; that is, when one light is ON, it must be distinguished from the case where the other light is ON. For instance, if the bulbs are A and B, then ‘A ON’ and ‘B OFF’ is a different code to ‘A OFF’ and ‘B ON’.

Computer circuits, however complex can be broken down into simpler and simpler subcircuits until we reach the fundamental building block from which the entire computer is made.  This building block is the electronic switch. The electronic switch is a circuit designed to always be in one of two states: ON or OFF. These states are similar to the positions of a physical switch.

When we use a computer to process information, the information is in binary form at every point of the process, from input to output. When you enter a document or a command you use the letter A-Z (both upper and lower cases), the number 0-9, and various other characters such as, *, =, + etc. Human beings understand these characters or symbols but the computer does not. In order for the computer to understand human information, this information must be digitised or converted to a format that the computer can understand and process. The computers understand information coded using 1s and 0s- Binary.

BITS, BYTES AND NIBBLES


                        4 bits               =          1 nibble
                        8 bits               =          1 byte
                        2 bytes             =          1 word
                        2 words           =          1 long word
                        1 kilobyte        =          210 bytes                      =          1024 bytes
                        1 megabyte      =          220 bytes                      =          1024 kb
                        1 gigabyte       =          230 bytes                      =          1024 MB
                        1 terabyte        =          240 bytes                      =          1024 GB        

BINARY CODING SCHEMES    

The two main coding schemes use by computers to represent data are ASCII and EBCDIC:

§      ASCII: American Standard Code for Information Interchange
-          Uses 7 bits to represent a character
-          Created by the USA government for use in micro and mini computers

§      EBCDIC: Extended Binary Coded Decimal Interchange Code
-          Uses 8 bits to represent a character
-          Created by International Business Machines  (IBM) for use in super and mainframe computers.

Bits in coding scheme
Possible combination of 1s and 0s
Size of character set
2
1,01,10,00
22 characters can be represented
3
111,110,100,001,011,101,010,000
23 characters can be represented
.
.
ASCII (7)
27 characters can be represented
EBCDIC (8)
28 characters can be represented

The coding schemes use by the computer determines the character set of the computer and the ability of the computer to display graphics and other information. The table above illustrates the character set depending on the amount of bits in the coding scheme. The ASCII coding scheme can represent 27 or 128 different characters. This includes all the letters of the alphabet, lower and upper case, the digit, special symbols and other graphics and control characters.

Bus line

A bus is line electronic pathway on which data travels between the primary components of the computer. The bus width determines the amount of data that can be carried at one time. Early microcomputer had a bus size of 8 bits so they could carry one character at a time. The present generation of microcomputers have bus sizes of 32 or 64 bits so they can carry four or eight counterpart. Some super computers have a bus size of 128 bits. If you type in the letter “A” it is converted to the binary “01000001” by your keyboard which sends the information to the CPU. The binary codes are sent to the CPU as a series of electronic pulses, maybe 5 volts represent 0. The pulses travel to the CPU along BUS LINES where they are stored electrically.

BINARY ALGEBRA


Digital computers use Binary Place Notion to store and represent values. The binary digit 0 and 1 only, are used in binary strings. A binary string is a sequence of two or more bits. Similar to the decimal system makes use of the position of each bit to determine the value represented by the binary number.

Conversion from decimal to binary

A simple method is to divide the decimal number repetitively by 2 recording the remainder in the next binary digit position, from bottom to top.

Conversion from binary to decimal

Values represented in binary strings can be converted to their decimal equivalent by adding the set decimal place values.

Addition of binary number

0   +   0   =   0
1   +   0   =   1
0   +   1   =   1
1   +   1   =   0    carry 1
1   +   1   +   1   =   1 carry 1

Converting a –ve decimal number to binary using sign & magnitude method

  1. Convert the decimal number to its binary value, ignoring the negative sign.
  2. Extend the bits to the appropriate length (i.e. one less than the size of the bit-string), by attaching 0s to the leftmost part of the bit string.
  3. Attach a 1 to the leftmost part of the bit string. The 1 is the sign bit it indicates that the number is negative. Alternatively, a 0 indicates that the number is positive.

Convert a sign & magnitude number to its decimal equivalent

  1. Convert the binary number to its decimal value ignoring the leftmost it in your calculations.
  2. If the leftmost bit is a 1 then the number is negative otherwise it is positive.

Ones Complement

To convert a binary number to its ones complement representation you change all the ones (1) to zeroes (0) and the zeroes (0) to one (1)

Twos Complement.
The twos complement of a binary number is formed by finding its ones complement and adding a one.

Converting a Negative decimal number to binary using the Twos Complement

  1. Convert the number to its binary value ignoring the sign
  2. Extend the bit string to the appropriate length (i.e. one less than the size of the bit-string), by attaching 0s to the leftmost part of the bit string.
  3. Find the ones complement
  4. Find the twos complement
  5. Attach a 1 to the leftmost part of the bit string. The 1 is the sign it indicates that the number is negative.

Converting a Positive decimal number to binary using the Twos Complement

To convert a positive binary number to its twos complement representation, we execute the following steps:
  1. Extend the bit string to the appropriate length (i.e. one less than the size of the bit-string), by attaching 0s to the leftmost part of the bit string.
  2. Attach a 0 to the leftmost part of the bit string, the 0 indicates that the binary number is positive

Converting a binary Twos Complement number to its decimal equivalent

Convert the binary number to its decimal equivalent, making the leftmost bit (the sign bit) binary place value negative.

Subtraction of Binary

To subtract two binary numbers using twos complement method, we convert both numbers to their twos complement representation and add them. To convert a positive binary number to its twos complement representation, we execute the following steps:
  1. Extend the bit string to the appropriate length(i.e. one less than the size of the bit-string), by attaching 0s to the leftmost part of the bit string.
  2. Attach a 0 to the leftmost part of the bit string, the 0 indicates that the binary number is positive

Binary Coded Decimal (BCD)
An alternative representation of integers is simply to represent the individual numerals which comprises them. This approach is consistent with the way in which we represent numbers ourselves. When we write the number 879, we are choosing to represent this number as three numerals: 8 (representing 800), 7 ( representing 70), 9(representing 9). So, we could convert this number to a binary form by converting each of the integers, one at a time, into binary a binary code. Such a scheme is referred to as binary coded decimal form, or BCD. The BCD codes commonly used to represent numerals are:


Numeral BCD Representation
0
1
2
3
4
5
6
7
8
9
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Using this scheme, we can represent any number by a string of binary digits.

Converting from decimal  to bicimal

In this method, we start by multiplying the denary number by 2. If the product has a whole number equal to zero, then we multiply the product again by 2. If however the product has a whole number equal to 1, then we remove the whole number 1 and multiply the decimal fraction remaining by 2. We continue in this manner until we obtain the required number of bicimal places. The denary number equivalent in base two is then obtained from the whole number 0 and 1 in the direction of the arrow shown, starting from the bicimal point.





DATA TYPES

There are two main data types called ‘name’ and ‘ number’. In the statement:

We can divide numbers into two kinds:
    1. whole numbers or integers;
    2. numbers with a decimal point, or real number.

3 is an example of an integer and 149.5 is a real number.  Note that a whole number is real if it is written with a decimal point. Thus:
25 is an integer, but
25.0 is real.

The difference is that inside a computer, the representation of 25 is very different from the representation of computer; the representation of 25 is very different from the representation of 25.0. Another answer is that, in some situations, it is better to use the integer than the real (or vice versa). Thus, we would say that Richard is taking 8 subjects rather than 8.0 subjects; also, since an average grade can contain a fractional part, it seems better to say that their averages were 72.6 and 60.0. In general, circumstances determine which data type – integer or real – it is best to use. An integer can be used to represent.

Strings

A person’s name is an example of a more general data type, called a string. A string is any sequence of characters.

Representation of characters

In computer terminology, a character can be any one of the following:
  1. a digit from 0 to 9;
  2. an upper case letter from A to Z
  3. a lower case from a to z;
  4. a special symbol like $,*,/,#,+,:,;,etc.

So characters are the symbols we use to express, in writing, whatever we wish to say. Since we would like to communicate our programs and data to the computer which, in turn, would communicate its results to us, the computer must be able to represent all the characters we may wish to use. We thus speak of the character set of a computer, meaning the set of characters, which the computer can represent and manipulate.

In order to represent the characters, all that is required is that a unique bit pattern be assigned to each character. Suppose that we wanted to represent the following:
  1. the ten digits 0 to 9;
  2. the 26 letters A to Z;
  3. 13 special characters.


PARITY

One track on the tape is not used for storing data, but is used as a control to make sure that the data recorded and transmitted is accurate; this is called parity track. For example, a 9-track tape uses 8 bits for storing data; the binary representation of the various characters would contain an even number of 1s in some cases and an odd number of 1s in others. For example, 10011100 contains four 1s (an even number) and 10011101 contains five 1s (an odd number). If the tape system is using even parity check, the parity bit (on the parity track) is set to 1 only if the character representation contains an odd number of 1s. This makes sure that each frame contains an even number of 1s. This makes sure that each frame is always even or always odd; this provides one method of checking the accuracy of the transmitted data.

No comments:

Post a Comment