Page 266 - ARM 64 Bit Assembly Language
P. 266
Non-integral mathematics 255
8.4.3.1 Results of fixed point division
Consider the results of dividing two fixed point numbers, using integer operations with limited
precision. The value of the least significant bit of the dividend N is 2 −f i and the value of the
least significant bit of the divisor D is 2 −f 2 . In order to perform the division using integer
f i
operations, it is necessary to multiply N by 2 and multiply D by 2 f 2 so that both numbers
are integers. Therefore the division operation can be written as:
N × 2 f 1 N
Q = = × 2 f 1 −f 2 .
f
D × 2 2 D
Note that no multiplication is actually performed. Instead, the programmer mentally shifts
the radix point of the divisor and dividend, then computes the radix point of the result. For
example, given two U(5,3) numbers, the division operation is accomplished by converting
them both to integers, performing the division, then computing the location of the radix point:
N × 2 3 N
0
Q = = × 2 .
D × 2 3 D
Note that the result is an integer. If the programmer wants to have some fractional bits in the
result, then the dividend must be shifted to the left before the division is performed.
If the programmer wants to have f q fractional bits in the quotient, then the amount that the
dividend must be shifted can easily be computed as
s = f q + f 1 − f 2 .
For example, suppose the programmer wants to divide 01001.011 stored as a U(28,3) by
00011.110 which is also stored as a U(28,3), and wishes to have six fractional bits in the
result. The programmer would first shift 01001.011 to the left by six bits, then perform the
division and compute the position of the radix in the result as shown:
01001.011 ÷ 00011.110 = (0000001001011000000 ÷ 00011110) × 2 −6−3+3
10100000 ×2 −6 = 10.100000
11110 1001011000000
111100000000
1111000000
1111000000
0
Since the divisor may be between zero and one, the quotient may actually require more inte-
ger bits than there are in the dividend. Consider that the largest possible value of the dividend