Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CMS_lab.doc
Скачиваний:
1
Добавлен:
10.11.2019
Размер:
325.63 Кб
Скачать

Contents of the Experimentation Paper

1. Principles of performing operations of multiplication in the binary system and DL representation.

2. Algorithms of subroutines for DL multiplication.

3. Examples of calculations using a subroutine.

Questions for the Self-Testing

1. What is the advantage of DL multiplication over multiplication done in the binary system?

2. What causes the multiplication error?

Laboratory work 4.2 realization of dl division operations

Aim of the work: Investigating of DL division operations.

Basic Principles

DL division is performed by an algorithm similar to “long division”. The trial digit of the quotient is defined as the difference between the most significant unit of the dividend (remainder) and the most significant unit of the divisor. If the remainder is negative, then the digit of the quotient is changed by -1. If the digit of the quotient is repeated, the correction is done again. The operation of division stops if:

1) no remainder has been obtained;

2) the predefined number of digits of the quotient has been obtained, i.e., the predefined accuracy is achieved;

3) an array element exceeds its maximal range;

4 ) the number of array elements has reached the limitation on its size.

Example. Given: A→{0,5,9.6.5.4.0} and B→{0,2,2.0}. Their quotient is to be found.

A flowchart of the DivDL subroutine for DL division is depicted in Fig. 4.2. The variables used here are: a is an array of integers that represent the DL dividend; b is an array of integers that represent the DL divisor; c is an array of integers that represent the DL quotient; i and j are cycles indices; e, f, and g are arrays of integers for intermediate computational results.

T he operands must be checked for their being equal to zero before starting the division. If the operand b is equal to zero, i.e., b[1]=0, the division is impossible and the routine is terminated abnormally (Error). If the operand a is equal to zero (a[1]=0), the result is also equal to zero (c[1]=0), and the routine is completed. Then we determine the sign of the quoti-ent: c[0] = a[0] b[0]. The sign of the operands a and b must be changed to positive since further transformations use their absolute values. The sign of the auxiliary e is also set positive and the number of its digits is set to 1.

The weight of the first significant digit of the quotient may be approximately defined as the difference between the weight of the first significant digit of the operand a and that of the operand b (i.e., i=a[2]-b[2]). Then this value of i is checked for being an element of the quotient. For this purpose the value i is used as the second element of the array e (e={0,1,i}), and is called the subroutine MultDL (see Lab. work 4.1), which performs DL multiplication of e and i, and the result is set to the array f. Then the subroutine SUB (see Lab. work 3.2) is called, which subtracts the product f from a and the result is set to the array g. If the difference g is equal to zero, the value of i is included as an element of the array c, and the division is completed. Otherwise, the sign of g is checked for being negative. If so, then the value of i is not included to the array c, it is decremented by 1 and the process of substitutions and checks continues. If g is positive (g[0]=0), the value of i is included to the array c, and the values of the array a elements are replaced by the values of the array g elements.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]