COA Notes UNIT 3 Part 1
COA Notes UNIT 3 Part 1
Data Representation: Data types, Complements, Fixed Point Representation, Floating Point
Representation.
Chapter 1: Data Representation: Data types, Complements, Fixed Point Representation, Floating Point
Representation.
1. Data Types
The data types found in the registers of digital computers may be classified as being one
of the following categories:
All types of data, except binary numbers, are represented in computer registers in
binary-coded form. This is because registers are made up of flip-flops and flip-flops are two-
state devices that can store only 1’s and 0’s.
Number Systems:
It can have different base values. The base number represents the number of digits used
in that numbering system.
Number Conversions:
Step 1: convert the integer part by doing successive division using the radix of asked number
systems.
Step 2: convert the fractional part by doing successive multiplication using radix of asked
number system
( 1010111)2
(1110)2
1st Multiplication Iteration
Multiply 0.625 by 2
0.625 x 2 = 1.25(Product) Fractional part=0.25 Carry=1 (MSB)
2nd Multiplication Iteration
Multiply 0.25 by 2
0.25 x 2 = 0.50(Product) Fractional part = 0.50 Carry = 0
3rd Multiplication Iteration
Multiply 0.50 by 2
0.50 x 2 = 1.00(Product) Fractional part = 1.00 Carry = 1 (LSB)
(101)2
The binary number of (16.625)10 is (1110.101)2
(410)8
The octal number of (264)10 is (410)8
Convert (105.589)10 decimal number to octal number
( 0.4554)
(.1013)
(1693.0628)10 = (69D.1013)16
Conversion of any number system to decimal number system:
Convert (101101001)2 to ( )8
Divide the binary into group of three digits from LSB we will find the following pattern
101|101|001
Now writing the equivalent decimal number of each group we get
5|5|1
So the equivalent octal number is 5518
Convert (11001100.101)2 to ( )8
011|001|100. |101|
314.5
So the equivalent octal number is 314.5
Convert (1A.2B)16 to ( )8
First convert hexadecimal to binary
The binary equivalent of 1A.2B is 00011010.00101011
Divide the binary into group of three digits
011|010|.|001|010|110
32.126
so the equivalent octal number is (32.126)8
2. Complements
In digital computers to simplify the subtraction operation and for logical manipulation
complements are used. There are two types of complements for each radix system the radix
complement and diminished radix complement. The first is referred to as the r’s complement
and the second as the (r-1)’s complement.
r’s Complement
Given a positive number N in base r with an integer part of n digits, the r’s
complement of N is defined as rn- N if N≠0 and 0 if N=0
(r-1)’s Complement
Given a positive number N in base r with an integer part of n digits, the (r-1)’s
complement of N is defined as (rn-1)-N
The subtraction of two positive numbers (M-N), both of base r, may be done as follows.
The procedure for subtraction with (r-1)’s complement is same as r’s complement
except for end-around carry.
The subtraction of M-N, both positive numbers in base r, may be calculated in the
following manner.
1. Add the minuend M to the (r-1)’s complement of the subtrahend N.
2. Inspect the result obtained in step 1 for an end carry.
*. If an end-carry occurs, add 1 to the least significant digit (end-around carry)
*. If an end-carry does not occur, take the (r-1)’s complement of the number
obtained in step 1 and place a negative sign in front.
1’s complement
2’s complement
9’s complement
10’s complement
The 1’s complement of a binary number is the number that results when we change all
ones to zeros and the zeros to ones.
The 2’s complement is the binary number that results when we add 1 to the 1’s
complement.
Subtraction of binary numbers can be accomplished by the direct method by using the
1’s complement method, which allows to perform subtraction using only addition . for
subtraction of two numbers we have two cases.
Method:
1. Determine the 2’s complement of the larger number.
2. Add the 2’s complement to the smaller number.
3. Answer is in 2’s complement form. To get the answer in true form take the 2’s
complement and assign negative sign to the answer.
9's complement and 10's complement:
Before knowing about 9's complement and 10's complement we should know why they
are used and why their concept came into existence. Addition of signed BCD numbers can be
performed by using 9’s and 10’s complement. The complements are used to make the
arithmetic operations in digital system easier. Various topics and related problems we going to
see here are
1. 9s complement
2. 10s complement
3. 9s complement subtraction
4. 10s complement subtraction
Now first of all let us know what 9's complement is and how it is done. To obtain the 9,s
complement of any number we have to subtract the number with (10n - 1) where n = number of
digits in the number, or in a simpler manner we have to divide each digit of the given decimal
number with 9.
Table 1. Will explain the 9’s complement more easily.
Now coming to 10's complement, it is relatively easy to find out the 10's complement
after finding out the 9,s complement of that number. We have to add 1 with the 9,s
complement of any number to obtain the desired 10's complement of that number. Or if we
want to find out the 10's complement directly, we can do it by following the formula, (10n -
number), where n = number of digits in the number. An example is given below to illustrate the
concept of obtaining 10’s complement.
A decimal number 456, find 9's complement and 10’s complement of this number
10’s complement is
The 10’s complement of the decimal is equal to 9’s complement plus 1. The 10’s
complement can be used to perform subtraction by adding the minuend to the 10’s
complement of the subtrahend and dropping the carry. This is explained with following
examples.
Steps for 10’s complement BCD subtraction:
3. Fixed-point Representation
In addition to the sign, a number may have a binary (or decimal) point. The position of
the binary point is needed to represent fractions, integers, or mixed integer-fraction numbers.
The representation of the binary point in a register is complicated by the fact that it is
characterized by a position in the register. There are two ways of specifying the position of the
binary point in a register: by giving it a fixed position or by employing a floating-point
representation. The fixed-point method assumes that the binary point is always fixed in one
position. The two positions most widely used are (1) a binary point in the extreme left of the
register to make the stored number a fraction, and (2) a binary point in the extreme right of the
register to make the stored number an integer. In either case, the binary point is not actually
present, but its presence is assumed from the fact that the number stored in the register is
treated as a fraction or as an integer.
Integer Representation
When an integer binary number is positive, the sign is represented by 0 and the
magnitude by a positive binary number. When the number is negative, the sign is represented
by 1 but the rest of the number may be represented in one of three possible ways:
1. Signed-magnitude representation
2. Signed-1’s complement representation
3. Signed 2’s complement representation
Arithmetic Addition
The addition of two numbers in the signed-magnitude system follows the rules of
ordinary arithmetic. If the signs are the same, we add the two magnitudes and give the sum the
common sign. If the signs are different, we subtract the smaller magnitude from the larger and
give the result the sign of the larger magnitude. For example, (+25) + (-37) = - (37 - 25) = -12 and
is done by subtracting the smaller magnitude 25 from the larger magnitude 37 and using the
sign of 37 for the sign of the result. This is a process that requires the comparison of the signs
and the magnitudes and then performing either addition or subtraction.
The rule for adding numbers in the signed-2’s complement system does not require a
comparison or subtraction, only addition and complementation. The procedure is very simple
and can be stated as follows: Add the two numbers, including their sign bits, and discard any
carry out of the sign (leftmost) bit position.
Numerical examples for addition are shown below. Note that negative numbers must
initially be in 2’s complement and that if the sum obtained after the addition is negative, it is in
2’s complement form.
In each of the four cases, the operation performed is always addition, including the sign
bits. Any carry out of the sign bit position is discarded, and negative results are automatically in
2’s complement form.
Arithmetic Subtraction
Subtraction of two signed binary numbers when negative numbers are in 2’s
complement form is very simple and can be stated as follows: Take the 2’s complement of the
subtrahend (including the sign bit) and add it to the minuend (including the sign bit). A carry out
of the sign bit position is discarded. This procedure stems from the fact that a subtraction
operation can be changed to an addition operation if the sign of the subtrahend is changed .This
is demonstrated by the following relationship:
But changing a positive number to a negative number is easily done by taking its 2’s
complement. The reverse is also true because the complement of a negative number in
complement form produces the equivalent positive number. Consider the subtraction of (-6) -
(-13) = +7. In binary with eight bits this is written as 11111010 - 11110011. The subtraction is
changed to addition by taking the 2’s complement of the subtrahend (-13) to give (+13). In
binary this is 11111010 + 00001101 = 100000111. Removing the end carry, we obtain the
correct answer 00000111 (-7).
It is worth noting that binary numbers in the signed-2’s complement system are added
and subtracted by the same basic addition and subtraction rules as unsigned numbers.
Therefore, computers need only one common hardware circuit to handle both types of
arithmetic. The user or programmer must interpret the results of such addition or subtraction
differently depending on whether it is assumed that the numbers are signed or unsigned.
4. Floating-point Representation
The floating-point representation of a number has two parts. The first part represents a
signed, fixed-point number called the mantissa. The second part designates the position of the
decimal (or binary) point and is called the exponent. The fixed-point mantissa may be a fraction
or an integer. For example, the decimal number +6132.789 is represented in floating-point with
a fraction and an exponent as follows:
The value of the exponent indicates that the actual position of the decimal point is four
positions to the right of the indicated decimal point in the fraction. This representation is
equivalent to the scientific notation +0.6132789 X 10+4.
The fraction has a 0 in the leftmost position to denote positive. The binary point of the
fraction follows the sign bit but is not shown in the register. The exponent has the equivalent
binary number +4. The floating-point number is equivalent to
Two main standard forms of floating-point numbers are from the following
organizations that decide standards: ANSI (American National Standards Institute) and IEEE
(Institute of Electrical and Electronic Engineers). The ANSI 32-bit floating-point numbers in byte
format with examples are given below: