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.
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:
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 * 10^{1}) + (3 * 10^{0})
4728 = (4 * 103) + (7 * 102) + (2 * ^{101)} + (8 * 10^{0})
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  10^{2}  10^{1}  10^{0} 
face value  4  5  3 
The above table indicates that:
The value of digit 4 = 4x10^{2} = 400
The value of digit 4 = 5x10^{1} = 50
The value of digit 3 = 3x10^{0} = 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

2^{3}

2^{2}

2^{1}

2^{0}

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:
74_{10} = 7 × 10^{1} + 4 × 10^{0}
In the octal system, each place is a power of eight. For example:
112_{8 }= 1 × 8^{2} + 1 × 8^{1} + 2 × 8^{0}
The place value of each digit according to position and weight is as follows.
Position

4

3

2

1

0

Weight

8^{4}

8^{3}

8^{2}

8^{1}

8^{0}

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 sixtyfour. 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

16^{4}

16^{3}

16^{2}

16^{1}

16^{0}

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).
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 (r1 complement)
For Binary Number System, the r’s complement is known as 2’s compliment and (r1)’s complement is 1’s compliment. For decimal Number System, r’s compliment is known as 10’s complement and (r1)’s Complement is 9’s complement.
r’s complement
r's complement of a number N is defined as r^{n} –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 (r1)'s complement.
Example:
(r1)'s Complement
(r1)'s complement of a number N is defined as (r^{n} 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 (r1)'s complement fast, subtract each digit of a number from (r1).
Example:
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 floatingpoint notation. (discussed later)
by giving it a fixed position (hence the name)
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 8bit representation of +14
Signed magnitude representation
Signed 1’s complement representation
Signed 2’s complement representation
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:
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.
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:
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 flipflop 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 FixedPoint 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 4bit decimal code requires 4 flipflops for each decimal digit. Example: 4385 = (0100 0011 1000 0101) _{BCD}
While using BCD representation,
For the representation of signed decimal numbers in BCD, sign is also represented with 4bits, 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]
References