Welcome to Edukum.com

Data Representation

Data Representation
Data types

The binary information is stored in memory or processor register. The register may contain data or control information. The data can be numbers or other binary coded information. The data in a register if digital computer can be categorized into following three types.

  1. The numbers used in arithmetic operations.
  2. Letters of the alphabet used in data processing
  3. Other discrete symbols used for specific purposes.

Number System

A set of values used to represent different quantities is known asNumber System.For example, a number system can be used to represent the number of students in a class or number of members in a family etc. The digital computer represents all kinds of data and information in binary numbers. It includes audio, graphics, video, text, and numbers. The total number of digits used in a number system is called its base or radix. The base is written after the number as subscript.

We can categorize number system as below:

  • Binary number system
  • Octal Number system
  • Decimal number system
  • Hexadecimal number system

Decimal Number System

The Decimal Number System consists of ten digits from 0 to 9. These digits can be used to represent any numeric value.

For example, 1274

The decimal system is said to have a base, or radix, of 10. This means that each digit in the number is multiplied by 10 raised to a power corresponding to that digit’s position:

83 = (8 * 101) + (3 * 100)

4728 = (4 * 103) + (7 * 102) + (2 * 101) + (8 * 100)

It is the most widely used number system.The value represented by individual digit depends on weight and position of the digit.

In any number, the leftmost digit is referred to as the most significant digit, because it carries the highest value. The rightmost digit is called the least significant digit. In the preceding decimal number, the 8 on the left is the most significant digit and the 3 on the right are the least significant digit.

Example:

The weights and positions of each digit of the number 453 are as follows:

Positions 2 1 0
weights 102 101 100
face value 4 5 3

The above table indicates that:

The value of digit 4 = 4x102 = 400

The value of digit 4 = 5x101 = 50

The value of digit 3 = 3x100 = 3

The actual number can be found by adding the values obtained by the digits as follows:

400 + 50 + 3 =45310

Binary Number System

Digital computer represents all kinds of data and information in the binary system. Binary Number System consists of two digits 0 and 1. Its base is 2. Each digit or bit in binary number system can be 0 or 1. A combination of binary numbers may be used to represent different quantities like 1001. The positional value of each digit in binary number is twice the place value or face value of the digit of its right side. The weight of each position is a power of 2.

The place value of the digits according to position and weight is as follows:

Position
3
2
1
0
Weights
23
22
21
20

Octal number system

Octal Number System consists of eight digits from 0 to 7. The base of octal system is 8. Each digit position in this system represents a power of 8. Any digit in this system is always less than 8. Octal number system is used as a shorthand representation of long binary numbers. The number 6418 is not valid in this number system as 8 is not a valid digit.

In the decimal system, each decimal place is a power of ten. For example:

7410 = 7 × 101 + 4 × 100

In the octal system, each place is a power of eight. For example:

1128 = 1 × 82 + 1 × 81 + 2 × 80

The place value of each digit according to position and weight is as follows.

Position
4
3
2
1
0
Weight
84
83
82
81
80

Hexadecimal Number System

The Hexadecimal Number System consists of 16 digits from 0 to 9 and A to F. The alphabets A to F represent decimal numbers from 10 to 15. The base of this number system is 16. Each digit position in hexadecimal system represents a power of 16. The number 76416 is valid hexadecimal number. It is different from 76410 which is seven hundred and sixty-four. This number system provides shortcut method to represent long binary numbers.

The place value of each digit according to position and weight is as follows:

Position
4
3
2
1
0
Weights
164
163
162
161
160

Alphanumeric Representation

Alphanumeric character set is a set of elements that includes the 10 decimal digits, 26 letters of the alphabet and special characters such as $, %, + etc. The standard alphanumeric binary code is ASCII(American Standard Code for Information Interchange) which uses 7 bits to code 128 characters (both uppercase and lowercase letters, decimal digits and special characters).

Alphanumeric_Representation
Partial ASCII Table

Compliments

In digital computers, complements are used for simplifying subtraction operation and logic manipulation. There are two types of compliments for binary as well as decimal number system.

Radix Complement (r’s complement)
Diminished Radix Complement (r-1 complement)

For Binary Number System, the r’s complement is known as 2’s compliment and (r-1)’s complement is 1’s compliment. For decimal Number System, r’s compliment is known as 10’s complement and (r-1)’s Complement is 9’s complement.

r’s complement

r's complement of a number N is defined as rn –N

Where N is the given number

r is the base of number system

n is the number of digits in the given number

To get the r's complement fast, add 1 to the low order digit of its (r-1)'s complement.

Example:

- 10's complement of 83510 is 16410 + 1 = 16510
- 2's complement of 10102 is 01012 + 1 = 01102

(r-1)'s Complement

(r-1)'s complement of a number N is defined as (rn -1) –N

Where N is the given number

r is the base of number system

n is the number of digits in the given number

To get the (r-1)'s complement fast, subtract each digit of a number from (r-1).

Example:

- 9's complement of 83510 is 16410. (Rule: (10n -1) –N)
- 1's complement of 10102 is 01012 (bit by bit complement operation)

Fixed Point Representation

The positive numbers are represented as unsigned numbers but for negative values. For example, the arithmetic uses plus ‘+’ or minus ‘-‘ sign to indicate positive or negative numbers. But in binary notation, o is used to indicate positive and 1 is used to indicate negative numbers. In addition to the sign, a number may have a binary or decimal point to represent fractions, integers or mixed integers.

There are two ways of specifying the position of a binary point in a resister:

by employing a floating-point notation. (discussed later)
by giving it a fixed position (hence the name)

  • Abinarypointintheextremeleftoftheresistertomakethestorednumberafraction.
  • Abinarypointintheextremerightofaresistertomakethestorednumberaninteger.

Integer representation
When the number is positive, a ‘0’ is used to represent the positive number or when the number is negative, the sign is represented by 1. And, the rest of the number is represented as by any one of the following method.Signed Magnitude representation
Signed 1’s complement representation
Signed 2’s complement representation

Consider, an 8-bit representation of +14

Signed magnitude representation

+14 à 00001110
-14 à 10001110

Signed 1’s complement representation

+14 à 01110001
-14 à 11110001

Signed 2’s complement representation

+14 à 01110010
-14 à 11110010

Arithmetic Addition

When the number is in single magnitude from the arithmetic addition, follows the same rule as ordinary arithmetic. For example: if the sign of two number are same, at two magnitudes and give the same common sign. If the sign are different, subtract smaller magnitude from the larger magnitude and give the result, the sign of larger magnitude.

If the number are in the 2’s complement, at two magnitudes including sign bit and discards any carry. If there is no carry, find the 2’s complement of the result and put minus sign.

Examples:

+6 00000110 +6 00000110
+13 00001101 -13 11110011
------------------- -------------
+19 00010011 -7 11111001

Arithmetic subtraction

The arithmetic subtraction is generally performed in 2’s complement form. For this, take 2’s compliment of the subtrahend including signed bit and add it to the minued including the signed bit. If there is any carry then discard it. This is similar to the condition if two sign of subtrahend is changed.

(±A) – (±B) = (±A) + (-B)

(±A) – (-B) = (±A) + (-B)

Changing a positive number into a negative number can be done by taking 2’s complement of the number. The binary number in signed 2’s complement system are added and subtracted by the same basic addition and subtraction rule as unsigned numbers. Therefore, computers need only one common hardware circuit to perform both types of arithmetic operations addition and subtraction.

Example:

(-6)-(-13) = +7, in binary with 8-bits this is written as:
-6 → 11111010
-13 → 11110011 (2's complement form)

Subtraction is changed to addition by taking 2's complement of the subtrahend (-13) to give (+13).
-6 → 11111010
+13 → 00001101
---------------------
+7 → 100000111 (discarding end carry).

Overflow

When two numbers of ‘n’ digits are added, the sum occupies ‘n+1’ digits. Then, it is called overflow. It is a problem in digital computers because the width of the register is infinite. The results that contains ‘n+1’ bits cannot be accommodated with the standard length register. When and overflow occurs, the corresponding flip-flop is set. The detection of overflow depends on the type of the number such as signed or unsigned or listed below:

When two unsigned numbers are added, an overflow can occur from end around carry of MSB.
In signed numbers, the leftmost bit represents the signed and the negative numbers are in 2’s complement form. When two signed numbers are added, the signed bit is treated as the part of the number and the end around carry does not indicate an overflow.
No overflow occurs if one number us positive and the other is negative.
The overflow can occur if both the numbers are positive or negative.

Overflow condition can be detected by observing the carry into the signed bit position. If two carries are not equal, an overflow condition can be produced. If two carries are applied to an exclusive OR gate, an overflow will be detected when the output of the gate is 1.

Decimal Fixed-Point Representation

Decimal number representation = f(binary code used to represent each decimal digit). Output of this function is called the Binary coded Decimal (BCD). A 4-bit decimal code requires 4 flip-flops for each decimal digit. Example: 4385 = (0100 0011 1000 0101) BCD

While using BCD representation,

  1. Disadvantages
    wastage of memory (Viz. binary equivalent of 4385 uses less bits than its BCD representation)
    Circuits for decimal arithmetic are quite complex.

  2. Advantages
    Eliminate the need for conversion to binary and back to decimal. (since applications like Business data processing requires less computation than I/O of decimal data, hence electronic calculators perform arithmetic operations directly with the decimal data (in binary code))

For the representation of signed decimal numbers in BCD, sign is also represented with 4-bits, plus with 4 0's and minus with 1001 (BCD equivalent of 9). Negative numbers are in 10's complement form.

Consider the addition: (+375) + (-240) = +135 [0àpositive, 9ànegative in case of radix 10]

0 375 (0000 0011 0111 0101)BCD
+9760 (1001 0111 0110 0000)BCD
------------------------------------­------------
0 135 (0000 0001 0011 0101)BCD
110 000100


References

"Data Representaiton." n.d. <http://www.csitnepal.com/elibrary/notes/>.
Computer Architecture/unit1

© 2019 EDUKUM.COM ALL RIGHTS RESERVED


#Things To Remember



1052 Views