You get a bonus - 1 coin for daily activity. Now you have 1 coin

9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

Lecture



Abstract: The lecture gives methods for dividing numbers with a fixed comma in direct codes and additional (inverse) codes. Operations on floating-point numbers - multiplication, division, addition, subtraction are described.

The implementation of the division operation in a computer in a binary number system is simpler than in decimal. This is due to the fact that in determining each private number, only one sample must be made.

If the numbers X and Y are given in the direct code, and they are represented with a fixed comma, then two basic algorithms are used to perform the division:

  • with shift and automatic balance recovery;
  • with a divider shift and automatic recovery of the remainder.

Let: [X] pk = sign X. x 1 x 2 ..x n

[Y] pc = sign Y. y 1 y 2 ..y n

[Z] pc = [X] pc / [Y] pc = sign Z. z 1 z 2 ..z n

X and Y must be such that:

| Z | <1 (i.e. fixed comma )

Direct code division with shift and automatic restoring of the remainder

  1.   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.
  2.   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.
  3. If a   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. , then z 0 = 1 and   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. (z 0 is the integer part of the result).

    If a   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. then z 0 = 0 and   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

etc.

Example :

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

+ 0.100 = [| X |] dk

1.010 = [- | Y |] dk

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

0.110 = [| Y |] dk

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

1.010 = [- | Y |] dk

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

0.110 = [| Y |] dk

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

Answer: [Z] pc = 1.101

Direct code division with divider shift and automatic remainder recovery

  •   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.
  •   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.
  • If a   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. then z 0 = 1.

    If a   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. then z 0 = 0.

      9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

Bit grid (n + d) bits, where d = log 2 n

Example :

  1) [X] 
PC
  = 1.1001
 2) [Y] 
PC
  = 1.1011
 n = 4, d = 2 
  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

Answer: [Z] pc = 0.1100

Example :

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.
  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

Answer: [Z] pc = 1.101

Division in additional (reverse) codes with shift and automatic recovery of the remainder

[X] dk, ok ; [Y] dk, ok

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

The division in the OK does not apply, since the "0" in the OK has a double image. In the first measure instead of   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. sign X is taken, and instead   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. is taken [x] dk, ok

Example :

  [X] 
dk
  = 1.0111 
 [Y] 
dk
  = 1.0011 
 Because  sign X = sign Y, then 

+ 1.0111 | 1.0011

0.1101 = - [Y] dk

______

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

1.0011 = [Y] dk

______

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

0.1101 = + [- [Y] dk ] dk

______

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

1.0011 = [Y] dk

______

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

0.1101 = + [- [Y] dk ] dk

______

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

Answer: [Z] dk = 0.1011

This is true when 0 <= [Z] dk = [X] dk / [Y] dk ] | <1.

If it is necessary to determine the quotient | [Z] dk = [X] dk / [Y] dk | | <2, then do this:

[X] dk * 2 -1 / [Y] dk = z 0 z 1 z 2 ... z n , z 0 is a sign, z 1 is the integer part of a number.

Arithmetic operations on floating-point numbers

The basis of arithmetic operations on floating-point numbers are the principles on which operations on numbers fixed by a comma are based. At the same time there are some features.

We will conditionally assume that the orders are given in the reverse code, and the mantissas in the direct one.

Multiplication:
  X = 2 
mx
  * sign Xx 
one
  x 
2
  ... x 
n
  Y = 2 
my
  * sign Yy 
one
  y 
2
  ... y 
n
  Z = X * Y = 2 
mx + my
  * sign Zz 
one
  z 
2
  ... z 
n

The order of the operation is as follows:

  1. The sign of the product is the same as when multiplying numbers with a fixed comma:

  2. The order of the product is found by algebraic summation of the orders of the multiplicand and the multiplier.
  3. The mantissa is found according to the rules for multiplying numbers with a fixed comma.

    The following cases are possible:

    • The mantissa of the work is an unnormalized number, since

        9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

      Therefore, it is necessary to normalize to the left a maximum of only one digit .

      To this end, you need to move the mantissa to the left by one digit . This corresponds to multiplying a number by 2 1 . In order for the number not to double, you need to subtract one from the order.

    • When multiplying two numbers due to the limitedness of the discharge grid, you can get a number that cannot be represented in it. This corresponds to the receipt of machine infinity.

      In this case, a special feature is produced, according to which further calculations are terminated.

    • When multiplying two numbers, you can get the minimum number, which also can not be represented in the bit grid. This corresponds to the case when the resulting number should be interpreted as zero .

Division

Basically analogous to multiplication:

  X = 2 
mx
  * sign Xx 
one
  x 
2
  ... x 
n
  Y = 2 
my
  * sign Yy 
one
  y 
2
  ... y 
n
  Z = X / Y = 2 
mx – my
  * sign Zz 
one
  z 
2
  ... z 
n

The order of the operation is as follows:

  1. By the well-known rules is the sign of the private
  2. The order of the quotient is found as the difference between the orders of the dividend and the divisor.
  3. Private figures are as follows:

    first is the whole part of the mantissa, i.e.   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

    If a   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. , if a   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. then z 0 = 0.

The fractional part of the mantissa is the same as in fixed-point operations on numbers. This procedure follows from the fact that:

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

That is, it is possible to obtain a non-normalized mantissa. To normalize, the mantissa must be shifted to the right by one digit and, in order not to reduce the result by a factor of two, it is necessary to add one unit to the order.

When dividing, as well as when multiplying, it is possible to obtain a machine zero code and an infinity code.

Addition and subtraction

Both operations are performed using similar algorithms.

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

The operation is performed as follows:

  1. The order difference is:   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.
  2. The alignment of the orders is made, while if the difference of orders is positive, then m x is taken as the result order, and the mantissa M y is shifted to the right by | m x - m y | discharges; If the order of digits is negative, then the mantissa M x is normalized.
  3. The algebraic summation of the mantis is made.
  4. Normalization is performed left or right for the corresponding number of digits with the necessary order correction.

Example :

  mantissa order
 [m 
x
  ] 
PC
  = 0.11 [M 
x
  ] 
PC
  = 0.1010
 [m 
y
  ] 
PC
  = 0.10 [M 
y
  ] 
PC
  = 0.1110
 Find the order difference:
    
+
  00.11 = [m 
x
  ] 
mock
  11.01 = [-m 
y
  ] 
mock
  1 |  00.00
    | _ _-> 1

00.01 =   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. - order difference.

  Since mx> m 
y
  , then:
        
+
  00.1010 = [M 
x
  ] 
mock
  00.0111 = [M 
y
  ] 
mock
  * 2 
-one
  [Z] wet = 01.0001 - overflow
          2 
-one
  * [Z] 
mock
  = 00.1000 - normalization
                 max (m 
x
  m 
y
  ) = [m 
x
  ] 
mock
  = 
+
  00.11
                               [one] 
mock
  = 00.01
                              [m 
x
  ] 
mock
  = 01.00 - order overflow

Z =   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. .

When performing the addition operation, the following specific cases are possible, called locks :

a) When determining the order difference, it may be necessary to shift the mantissa of one of the numbers by an amount greater than the number of digits in the discharge grid. In this case, naturally, such a number can be perceived as zero, and the further addition operation can be blocked, that is, not performed.

The maximum number is taken as a result.

Example :

  [m 
x
  ] 
OK
  = 0.101 [M 
x
  ] 
OK
  = 0.10111101
 [m 
y
  ] 
OK
  = 1.001 [M 
y
  ] 
OK
  = 0.10000001 

Order difference:

+
  00.101 = [m 
x
  ] 
mock
  00.110 = [-m 
y
  ] 
mock

  9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes. - that is, this number is 11 10 , and in the discharge grid of the mantissa there are only 8 bits.

Therefore, the operation is blocked, and the result is a number:

  [m 
x
  ] = 0.101 [M 
x
  ] = 0.10111101 

A similar case may occur when the order difference is negative (negative overflow). In this case, the operation is also blocked, and the result will be a number with the maximum order.

Example :

  [m 
x
  ] 
OK
  = 1.010 [M 
x
  ] 
OK
  = 1.10101011
 [m 
y
  ] 
OK
  = 0.110 [M 
y
  ] 
OK
  = 1.11111111 

Order difference:

+
  11.010 = [m 
x
  ] 
mock
  11.001 = [-m 
y
  ] 
mock
  _______
+
  1 |  10.011
          one
    _______ 

10,100 =   9. methods of dividing numbers with a fixed comma in direct codes and additional (inverse) codes.

That is, the difference in orders is less (-8).

The operation is blocked, and the result will be a number:

  [m 
y
  ] 
OK
  = 0.110 [M 
y
  ] 
OK
  = 1.11111111 

Decimal binary coded systems.

Sometimes computers use decimal number systems. It is beneficial to use them when the amount of input data for processing on a computer is large, the processing itself is carried out according to relatively simple programs. This results in a significant time saving, which follows from the fact that it is not necessary to do a transfer from decimal to binary and vice versa.

As a rule, the AU, which works with numbers in the decimal number system, is introduced into the equipment of such computers. Since a trigger cell with two stable states is used as the main storage element, each decimal digit is encoded by a set of binary symbols.

Conversion of numbers from the decimal system to the decimal binary-coded is performed extremely simply, bitwise and simultaneously across the entire grid:

  879.65_10 -> 1000 0111 1001, 0110 010110 ^ -2 

Similarly, a reverse translation is performed:

  0110 1001, 0101 0011 
10 ^ -2
  -> 69, 53 
ten

There is a wide variety of decimal binary coded systems. This diversity results from the redundancy of the binary code, in which out of the 16 possible combinations in each digit, only 10 are used for the direct information purpose.

The most widely used are coding systems 8421 and 8421 +3 (Stibitz code).

System 8421 is inconvenient because when performing the subtraction operation there is no direct transition from the digit of each digit to the additional code.

0000 - 0

0001 - 1

0010 - 2

0011 - 3

0100 - 4

0101 - 5

0110 - 6

0111 - 7

1000 - 8

1001 - 9

At the same time, this system has the additivity property, since the results of the addition operation over the numbers in the decimal system and over their image in the 8421 system coincide.

System 8421 +3 - more interesting, because it has the property of self-completion. It is seen that the addition to 9 can be obtained by applying the bitwise inversion of the code.

0011 - 0

0100 - 1

0101-2

0110 - 3

0111 - 4

1000 - 5

1001 - 6

1010 - 7

1011 - 8

1100 - 9

In total there is A 16 10 = 2.9 • 10 10 variants of the 10th binary-coded systems.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Digital devices. Microprocessors and microcontrollers. computer operating principles

Terms: Digital devices. Microprocessors and microcontrollers. computer operating principles