JPH04348424A - Integer division system - Google Patents
Integer division systemInfo
- Publication number
- JPH04348424A JPH04348424A JP3120921A JP12092191A JPH04348424A JP H04348424 A JPH04348424 A JP H04348424A JP 3120921 A JP3120921 A JP 3120921A JP 12092191 A JP12092191 A JP 12092191A JP H04348424 A JPH04348424 A JP H04348424A
- Authority
- JP
- Japan
- Prior art keywords
- divisor
- dividend
- value
- showing
- division
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 claims description 5
- 238000000605 extraction Methods 0.000 abstract 1
- 238000004891 communication Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000007796 conventional method Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
Abstract
Description
【0001】0001
【産業上の利用分野】本発明は、情報処理に係り、特に
RISC(リデュースト・インストラクション・セット
・コンピュータ:Reduced Instructi
on Set Computer)等の乗除算命令のな
いコンピュータにおける除算操作を高速に実行する方式
に関する。[Field of Industrial Application] The present invention relates to information processing, and particularly to RISC (Reduced Instruction Set Computer).
The present invention relates to a method for quickly executing a division operation on a computer that does not have multiplication/division instructions, such as on-set computers.
【0002】0002
【従来の技術】従来、整数除算に関する技術としては、
”インテジャ・マルティプリケーション・アンド・ディ
ヴィジョン・オン・ザ・エッチピー・プリンジョン・ア
ーキテクチャ:Integer Multiplica
tion and Division on the
HP Precision Architecture
”コミュケーション・オブ・ザ・エーシーエム: Co
mmunications of the ACM,v
ol14,no.10,oct.1987,pp.90
−99において論じられている。本文献では、除数の逆
数をあらかじめ求めておき、被除数に1を加えた値にそ
の除数の逆数を乗じることで、除算を実現している。し
かし、一部の除数のケースでは、他のケースより高い精
度の演算が必要となり、除算の実行速度が低下する欠点
があった。[Prior Art] Conventionally, as a technique related to integer division,
”Integer Multiplication and Division on the Hp Prination Architecture: Integer Multiplica
tion and Division on the
HP Precision Architecture
“Communication of the ACM: Co.
communications of the ACM, v.
ol14, no. 10, oct. 1987, pp. 90
-99. In this document, division is realized by calculating the reciprocal of the divisor in advance and multiplying the value obtained by adding 1 to the dividend by the reciprocal of the divisor. However, in some divisor cases, higher precision calculations are required than in other cases, which has the disadvantage of reducing the execution speed of division.
【0003】0003
【発明が解決しようとする課題】上記の従来技術では、
一部の除数のケースにおいて、他のケースより高い精度
の演算を必要とするという問題があった。[Problem to be solved by the invention] In the above conventional technology,
There is a problem in that some divisor cases require higher precision calculations than other cases.
【0004】本発明の目的は、当該除数のケースについ
ても、他の場合と同じ精度の演算で除算操作を実現し、
除算の実行速度を向上することにある。An object of the present invention is to realize a division operation with the same precision in the case of the divisor as in other cases,
The purpose is to improve the execution speed of division.
【0005】[0005]
【課題を解決するための手段】上記の目的は、被除数に
除数の逆数を乗じる前に、被除数を適当な値で補正する
ことで達成される。[Means for Solving the Problems] The above object is achieved by correcting the dividend with an appropriate value before multiplying the dividend by the reciprocal of the divisor.
【0006】すなわち、各記号を以下のように定義した
とき、
x: 被除数(値は正とする)
y: 除数(値は正の奇数とする)
n: 被除数の精度(被除数の最大値=2**n−1
)a: 除数の逆数(=[2**m/y]但し、m≧
n−1)
r: 除数の逆数を求めたときの余り(=2**n−
a・y)
商Pは、
P = [a・(x+1+[r・x/2**m
])/2**m] (数1)の式で求められる。That is, when each symbol is defined as follows, x: Dividend (value is positive) y: Divisor (value is a positive odd number) n: Precision of dividend (maximum value of dividend = 2) **n-1
) a: Reciprocal of divisor (=[2**m/y] where m≧
n-1) r: Remainder when calculating the reciprocal of the divisor (=2**n-
a・y) The quotient P is P = [a・(x+1+[r・x/2**m
])/2**m] (Equation 1).
【0007】この式より、前述の従来技術は、r=1の
ときの特定なケースについての技術であり、本発明は、
これをより一般化したものとしてとらえることができる
。From this equation, the above-mentioned prior art is a technology for a specific case when r=1, and the present invention
This can be seen as a more generalized version.
【0008】mの値は、以下のようにして決定する。The value of m is determined as follows.
【0009】(1)m=nのときrが2のべき数なら、
m=nとして「数1」の演算をする。(1) When m=n, if r is a power of 2, then
Calculate "Equation 1" with m=n.
【0010】(2)m=nのときrが2のべき数でない
なら、m=n+1,...n+k(但し、k=[log
2 y])についてrの値を求め、rが2のべき数(r
=1が最初に見つかる)になるmについて「数1」の演
算をする。(2) When m=n, if r is not a power of 2, then m=n+1, . .. .. n+k (however, k=[log
2 y]), find the value of r for r
1 is found first).
【0011】(3)上記範囲でrが2のべき数にならな
いなら、同じ範囲で、今度は、(r/2**(m−n+
1))<1 を満足するmについて、「数1」の演算
をする。(3) If r does not become a power of 2 in the above range, then in the same range, (r/2**(m-n+
1) Calculate "Equation 1" for m that satisfies <1.
【0012】(4)m=n−1において、rが2のべき
数なら、2**(n−1)> x ≧0 のとき
m=n−1として「数1」の演算をする。(4) When m=n-1, if r is a power of 2, then when 2**(n-1)>x≧0, m=n-1 and the calculation of "Equation 1" is performed.
【0013】2**(n−1)+(y−r)> x
≧2**(n−1) のとき商pはaとする。2**(n-1)+(yr)>x
When ≧2**(n-1), the quotient p is set to a.
【0014】2**n> x ≧2**(n−1)
+(y−r) のときxから2**(n−1)+(y
−r)を減じ、m=n−1として「数1」の演算をした
後、商pにa+1を加える。[0014] 2**n> x ≧2**(n-1)
+(yr-r), then x to 2**(n-1)+(y
-r), and after performing the calculation of "Equation 1" with m=n-1, a+1 is added to the quotient p.
【0015】[0015]
【表1】[Table 1]
【0016】以上、いずれの条件も満たさないケースに
ついては、本発明の適用外であるが、表1に示すように
、n=32の場合、43以下のyについて、適用外とな
るのは25と41の場合だけである。[0016] The present invention is not applicable to cases where none of the above conditions are satisfied, but as shown in Table 1, when n = 32, the cases where y is 43 or less are not applicable are 25 and 41 cases only.
【0017】[0017]
【作用】前項の説明では、被除数、除数がともに正の場
合で、除数は奇数に限定してあるが、負の場合は、一旦
正に変換して演算し、その後符号調整を行えば良く、ま
た、除数が偶数のケースは、被除数を2で割ったのち前
項の手段を適用すれば良い。[Operation] In the explanation in the previous section, both the dividend and the divisor are positive, and the divisor is limited to odd numbers. However, in the case of a negative number, it is sufficient to first convert it to a positive value and then perform the calculation, and then adjust the sign. Furthermore, in the case where the divisor is an even number, the method described in the previous section may be applied after dividing the dividend by 2.
【0018】「数1」の演算において、[r・x/2*
*m]の値は、xの先頭log2 rビットを取り出す
ことで実現できる。但し、r=1のときは、何もしなく
て良い。また、aの乗算及びその後の切捨て操作は、ビ
ットシフト命令と加減算命令との組み合わせで実現でき
、全体として高速な除算操作が可能となる。In the operation of “Math 1”, [r・x/2*
*m] can be realized by extracting the first log2 r bits of x. However, when r=1, there is no need to do anything. Further, the multiplication of a and the subsequent truncation operation can be realized by a combination of a bit shift instruction and an addition/subtraction instruction, making it possible to perform a high-speed division operation as a whole.
【0019】「数1」の演算で必要な精度は、前項(1
)の場合、
(x+1+[r・x/2**m])はn+1ビット、a
はn−kビットなので、「数1」全体としては2・n−
k+1ビットとなる。[0019] The precision required for the calculation of "Math 1" is as follows (1
), (x+1+[r・x/2**m]) is n+1 bits, a
is n-k bits, so the whole number 1 is 2・n-
It becomes k+1 bits.
【0020】前項(2)、(3)の場合、(x+1+[
r・x/2**m])はn+1ビット、aは最大nビッ
トとなるので、「数1」全体としては2・n+1ビット
となるが、実際には、(x+1+[r・x/2**m]
)の値が小さいため、「数1」全体として2・nビット
で十分である。In the case of (2) and (3) above, (x+1+[
r. **m]
) is small, 2·n bits are sufficient for the entire equation 1.
【0021】以上から、すべてのケースについて、n=
32とすれば64ビットの倍精度演算、n=16とすれ
ば32ビットの単精度演算で十分である。From the above, for all cases, n=
If n=32, 64-bit double-precision arithmetic is sufficient, and if n=16, 32-bit single-precision arithmetic is sufficient.
【0022】[0022]
【実施例】以下に本発明の一実施例を示す。なお、本実
施例では、発明の手段の項の項番(4)のケースを例に
とっている。図1は、被除数の精度が16ビットで、除
数が13のときの整数除算プログラムのフローチャート
である。図1の右側の数値は、xの値が(FFFD)1
6のときの各ステップでの各変数の値を示している。な
お、図1での数値はすべて16進表示である。[Example] An example of the present invention is shown below. In this embodiment, the case of item number (4) in the section of means of the invention is taken as an example. FIG. 1 is a flowchart of an integer division program when the precision of the dividend is 16 bits and the divisor is 13. The numbers on the right side of Figure 1 indicate that the value of x is (FFFD)1
6 shows the value of each variable at each step. Note that all numerical values in FIG. 1 are expressed in hexadecimal.
【0023】ステップ1、2及び3で、被除数の値の範
囲を調べている。In steps 1, 2, and 3, the range of values of the dividend is examined.
【0024】ステップ4は、2**(n−1)+(y−
r)> x ≧2**(n−1)のケースであり、
除数の逆数そのものが結果となる。Step 4 is 2**(n-1)+(y-
r)> x ≧2**(n-1),
The reciprocal of the divisor itself is the result.
【0025】ステップ5では、[r・x/2**m]の
値を求めている。In step 5, the value of [r·x/2**m] is determined.
【0026】逆数aの値(9D8)16は(((40)
16−1)*5)*8と表現できるので、ステップ6、
7、8、9、10において、この値とxとの積を計算す
る。
なお、ステップ10では、最後の8倍と、2**15で
の除算とを一度に実行している。ステップ11では、商
の補正のため、逆数+1を加えている。これにより、除
数13での除算が完了する。The value of the reciprocal a (9D8)16 is (((40)
It can be expressed as 16-1)*5)*8, so step 6,
7, 8, 9, and 10, calculate the product of this value and x. Note that in step 10, the final multiplication by 8 and division by 2**15 are executed at the same time. In step 11, the reciprocal +1 is added to correct the quotient. This completes the division by the divisor 13.
【0027】[0027]
【発明の効果】本発明によれば、比較的精度の低い加減
算及びビットシフト操作だけで除算操作が完了するため
、高速な除算を実現できる。すなわち、従来の技術では
、6、7、8、9、10の各ステップにおいて倍精度の
演算を必要としたのに対し、本方式では、単精度の演算
で十分である。According to the present invention, a division operation can be completed only by addition/subtraction and bit shift operations with relatively low precision, so that high-speed division can be realized. That is, whereas the conventional technique required double-precision calculations in each step of 6, 7, 8, 9, and 10, in this method, single-precision calculations are sufficient.
【図1】被除数の精度が16ビットで、除数が13のと
きの整数除算プログラムのフローチャートである。FIG. 1 is a flowchart of an integer division program when the precision of the dividend is 16 bits and the divisor is 13;
Claims (1)
まった定数のとき、被除数を補正することで、加減算と
ビットシフト操作だけで商を求めることを特徴とする整
数除算方式。1. An integer division method characterized in that, in integer division, when the divisor is a predetermined constant, the quotient is determined by correcting the dividend using only addition, subtraction, and bit shift operations.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP3120921A JPH04348424A (en) | 1991-05-27 | 1991-05-27 | Integer division system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP3120921A JPH04348424A (en) | 1991-05-27 | 1991-05-27 | Integer division system |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH04348424A true JPH04348424A (en) | 1992-12-03 |
Family
ID=14798289
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP3120921A Pending JPH04348424A (en) | 1991-05-27 | 1991-05-27 | Integer division system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH04348424A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003076557A (en) * | 2001-08-31 | 2003-03-14 | Fujitsu Ltd | Development system of microprocessor for application program including integer division or integer remainder calculation |
-
1991
- 1991-05-27 JP JP3120921A patent/JPH04348424A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2003076557A (en) * | 2001-08-31 | 2003-03-14 | Fujitsu Ltd | Development system of microprocessor for application program including integer division or integer remainder calculation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP2002108606A (en) | Sticky bit generating circuit and multiplier | |
US9959093B2 (en) | Binary fused multiply-add floating-point calculations | |
JP3345894B2 (en) | Floating point multiplier | |
US6182100B1 (en) | Method and system for performing a logarithmic estimation within a data processing system | |
US10296294B2 (en) | Multiply-add operations of binary numbers in an arithmetic unit | |
JP2502836B2 (en) | Preprocessing device for division circuit | |
US9348796B2 (en) | Arithmetic operation in a data processing system | |
EP1695203A1 (en) | Floating-point operations using scaled integers | |
CN109901813B (en) | Floating point operation device and method | |
US7080112B2 (en) | Method and apparatus for computing an approximation to the reciprocal of a floating point number in IEEE format | |
US7401107B2 (en) | Data processing apparatus and method for converting a fixed point number to a floating point number | |
US6697833B2 (en) | Floating-point multiplier for de-normalized inputs | |
JPH04348424A (en) | Integer division system | |
US5377134A (en) | Leading constant eliminator for extended precision in pipelined division | |
US20140052767A1 (en) | Apparatus and architecture for general powering computation | |
JP3064405B2 (en) | Complex number processing | |
JP2645422B2 (en) | Floating point processor | |
JP3201097B2 (en) | Multiplication prescription method in multiplier | |
KR100974190B1 (en) | Complex number multiplying method using floating point | |
EP2884403A1 (en) | Apparatus and method for calculating exponentiation operations and root extraction | |
JPS59116852A (en) | High-speed divider | |
JP2753922B2 (en) | Fixed-point division method | |
JPH0285922A (en) | Arithmetic circuit | |
JPS58155456A (en) | Information processing device | |
JPH06168105A (en) | Integer dividing system |