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:
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 )
If a , then z 0 = 1 and (z 0 is the integer part of the result).
If a then z 0 = 0 and
etc.
Example :
+ 0.100 = [| X |] dk
1.010 = [- | Y |] dk
0.110 = [| Y |] dk
1.010 = [- | Y |] dk
0.110 = [| Y |] dk
Answer: [Z] pc = 1.101
If a then z 0 = 1.
If a then z 0 = 0.
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
Answer: [Z] pc = 0.1100
Example :
Answer: [Z] pc = 1.101
[X] dk, ok ; [Y] dk, ok
The division in the OK does not apply, since the "0" in the OK has a double image. In the first measure instead of sign X is taken, and instead 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
______
1.0011 = [Y] dk
______
0.1101 = + [- [Y] dk ] dk
______
1.0011 = [Y] dk
______
0.1101 = + [- [Y] dk ] dk
______
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.
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.
X = 2mx
* sign Xxone
x2
... xn
Y = 2my
* sign Yyone
y2
... yn
Z = X * Y = 2mx + my
* sign Zzone
z2
... zn
The order of the operation is as follows:
The sign of the product is the same as when multiplying numbers with a fixed comma:
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
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 .
Basically analogous to multiplication:
X = 2mx
* sign Xxone
x2
... xn
Y = 2my
* sign Yyone
y2
... yn
Z = X / Y = 2mx – my
* sign Zzone
z2
... zn
The order of the operation is as follows:
Private figures are as follows:
first is the whole part of the mantissa, i.e.
If a , if a 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:
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.
Both operations are performed using similar algorithms.
The operation is performed as follows:
Example :
mantissa order [mx
]PC
= 0.11 [Mx
]PC
= 0.1010 [my
]PC
= 0.10 [My
]PC
= 0.1110 Find the order difference:+
00.11 = [mx
]mock
11.01 = [-my
]mock
1 | 00.00 | _ _-> 1
00.01 = - order difference.
Since mx> my
, then:+
00.1010 = [Mx
]mock
00.0111 = [My
]mock
* 2-one
[Z] wet = 01.0001 - overflow 2-one
* [Z]mock
= 00.1000 - normalization max (mx
my
) = [mx
]mock
=+
00.11 [one]mock
= 00.01 [mx
]mock
= 01.00 - order overflow
Z = .
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 :
[mx
]OK
= 0.101 [Mx
]OK
= 0.10111101 [my
]OK
= 1.001 [My
]OK
= 0.10000001
Order difference:
00.101 = [mx
]mock
00.110 = [-my
]mock
- 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:
[mx
] = 0.101 [Mx
] = 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 :
[mx
]OK
= 1.010 [Mx
]OK
= 1.10101011 [my
]OK
= 0.110 [My
]OK
= 1.11111111
Order difference:
11.010 = [mx
]mock
11.001 = [-my
]mock
_______+
1 | 10.011 one _______
10,100 =
That is, the difference in orders is less (-8).
The operation is blocked, and the result will be a number:
[my
]OK
= 0.110 [My
]OK
= 1.11111111
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 001110 ^ -2
-> 69, 53ten
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
Digital devices. Microprocessors and microcontrollers. computer operating principles
Terms: Digital devices. Microprocessors and microcontrollers. computer operating principles