JPH04348424A - 整数除算方式 - Google Patents

整数除算方式

Info

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
Application number
JP3120921A
Other languages
English (en)
Inventor
Atsuo Anzaki
安崎 篤郎
Shigeki Yamamoto
山本 重樹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Software Engineering Co Ltd
Hitachi Ltd
Original Assignee
Hitachi Software Engineering Co Ltd
Hitachi Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hitachi Software Engineering Co Ltd, Hitachi Ltd filed Critical Hitachi Software Engineering Co Ltd
Priority to JP3120921A priority Critical patent/JPH04348424A/ja
Publication of JPH04348424A publication Critical patent/JPH04348424A/ja
Pending legal-status Critical Current

Links

Abstract

(57)【要約】本公報は電子出願前の出願データであるた
め要約のデータは記録されません。

Description

【発明の詳細な説明】
【0001】
【産業上の利用分野】本発明は、情報処理に係り、特に
RISC(リデュースト・インストラクション・セット
・コンピュータ:Reduced Instructi
on Set Computer)等の乗除算命令のな
いコンピュータにおける除算操作を高速に実行する方式
に関する。
【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を加えた値にそ
の除数の逆数を乗じることで、除算を実現している。し
かし、一部の除数のケースでは、他のケースより高い精
度の演算が必要となり、除算の実行速度が低下する欠点
があった。
【0003】
【発明が解決しようとする課題】上記の従来技術では、
一部の除数のケースにおいて、他のケースより高い精度
の演算を必要とするという問題があった。
【0004】本発明の目的は、当該除数のケースについ
ても、他の場合と同じ精度の演算で除算操作を実現し、
除算の実行速度を向上することにある。
【0005】
【課題を解決するための手段】上記の目的は、被除数に
除数の逆数を乗じる前に、被除数を適当な値で補正する
ことで達成される。
【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)の式で求められる。
【0007】この式より、前述の従来技術は、r=1の
ときの特定なケースについての技術であり、本発明は、
これをより一般化したものとしてとらえることができる
【0008】mの値は、以下のようにして決定する。
【0009】(1)m=nのときrが2のべき数なら、
m=nとして「数1」の演算をする。
【0010】(2)m=nのときrが2のべき数でない
なら、m=n+1,...n+k(但し、k=[log
2 y])についてrの値を求め、rが2のべき数(r
=1が最初に見つかる)になるmについて「数1」の演
算をする。
【0011】(3)上記範囲でrが2のべき数にならな
いなら、同じ範囲で、今度は、(r/2**(m−n+
1))<1  を満足するmについて、「数1」の演算
をする。
【0012】(4)m=n−1において、rが2のべき
数なら、2**(n−1)>  x  ≧0  のとき
m=n−1として「数1」の演算をする。
【0013】2**(n−1)+(y−r)>  x 
 ≧2**(n−1)  のとき商pはaとする。
【0014】2**n>  x  ≧2**(n−1)
+(y−r)  のときxから2**(n−1)+(y
−r)を減じ、m=n−1として「数1」の演算をした
後、商pにa+1を加える。
【0015】
【表1】
【0016】以上、いずれの条件も満たさないケースに
ついては、本発明の適用外であるが、表1に示すように
、n=32の場合、43以下のyについて、適用外とな
るのは25と41の場合だけである。
【0017】
【作用】前項の説明では、被除数、除数がともに正の場
合で、除数は奇数に限定してあるが、負の場合は、一旦
正に変換して演算し、その後符号調整を行えば良く、ま
た、除数が偶数のケースは、被除数を2で割ったのち前
項の手段を適用すれば良い。
【0018】「数1」の演算において、[r・x/2*
*m]の値は、xの先頭log2 rビットを取り出す
ことで実現できる。但し、r=1のときは、何もしなく
て良い。また、aの乗算及びその後の切捨て操作は、ビ
ットシフト命令と加減算命令との組み合わせで実現でき
、全体として高速な除算操作が可能となる。
【0019】「数1」の演算で必要な精度は、前項(1
)の場合、 (x+1+[r・x/2**m])はn+1ビット、a
はn−kビットなので、「数1」全体としては2・n−
k+1ビットとなる。
【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ビット
で十分である。
【0021】以上から、すべてのケースについて、n=
32とすれば64ビットの倍精度演算、n=16とすれ
ば32ビットの単精度演算で十分である。
【0022】
【実施例】以下に本発明の一実施例を示す。なお、本実
施例では、発明の手段の項の項番(4)のケースを例に
とっている。図1は、被除数の精度が16ビットで、除
数が13のときの整数除算プログラムのフローチャート
である。図1の右側の数値は、xの値が(FFFD)1
6のときの各ステップでの各変数の値を示している。な
お、図1での数値はすべて16進表示である。
【0023】ステップ1、2及び3で、被除数の値の範
囲を調べている。
【0024】ステップ4は、2**(n−1)+(y−
r)>  x  ≧2**(n−1)のケースであり、
除数の逆数そのものが結果となる。
【0025】ステップ5では、[r・x/2**m]の
値を求めている。
【0026】逆数aの値(9D8)16は(((40)
16−1)*5)*8と表現できるので、ステップ6、
7、8、9、10において、この値とxとの積を計算す
る。 なお、ステップ10では、最後の8倍と、2**15で
の除算とを一度に実行している。ステップ11では、商
の補正のため、逆数+1を加えている。これにより、除
数13での除算が完了する。
【0027】
【発明の効果】本発明によれば、比較的精度の低い加減
算及びビットシフト操作だけで除算操作が完了するため
、高速な除算を実現できる。すなわち、従来の技術では
、6、7、8、9、10の各ステップにおいて倍精度の
演算を必要としたのに対し、本方式では、単精度の演算
で十分である。
【図面の簡単な説明】
【図1】被除数の精度が16ビットで、除数が13のと
きの整数除算プログラムのフローチャートである。

Claims (1)

    【特許請求の範囲】
  1. 【請求項1】整数の除算において、除数があらかじめ定
    まった定数のとき、被除数を補正することで、加減算と
    ビットシフト操作だけで商を求めることを特徴とする整
    数除算方式。
JP3120921A 1991-05-27 1991-05-27 整数除算方式 Pending JPH04348424A (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP3120921A JPH04348424A (ja) 1991-05-27 1991-05-27 整数除算方式

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP3120921A JPH04348424A (ja) 1991-05-27 1991-05-27 整数除算方式

Publications (1)

Publication Number Publication Date
JPH04348424A true JPH04348424A (ja) 1992-12-03

Family

ID=14798289

Family Applications (1)

Application Number Title Priority Date Filing Date
JP3120921A Pending JPH04348424A (ja) 1991-05-27 1991-05-27 整数除算方式

Country Status (1)

Country Link
JP (1) JPH04348424A (ja)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003076557A (ja) * 2001-08-31 2003-03-14 Fujitsu Ltd 整数除算または整数剰余算を含むアプリケーションプログラム向けのマイクロプロセッサの開発システム

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003076557A (ja) * 2001-08-31 2003-03-14 Fujitsu Ltd 整数除算または整数剰余算を含むアプリケーションプログラム向けのマイクロプロセッサの開発システム

Similar Documents

Publication Publication Date Title
JP2002108606A (ja) スティッキービット生成回路及び乗算器
US9959093B2 (en) Binary fused multiply-add floating-point calculations
CN109901813B (zh) 一种浮点运算装置及方法
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 (ja) 除算回路の前処理装置
US9348796B2 (en) Arithmetic operation in a data processing system
EP1695203A1 (en) Floating-point operations using scaled integers
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
US20200183650A1 (en) Radix-1000 decimal floating-point numbers and arithmetic units using a skewed representation of the fraction
JPH04348424A (ja) 整数除算方式
US5377134A (en) Leading constant eliminator for extended precision in pipelined division
US20140052767A1 (en) Apparatus and architecture for general powering computation
JP3064405B2 (ja) 複素数の演算処理方式
JP2645422B2 (ja) 浮動小数点演算処理装置
JP3201097B2 (ja) 乗算器における乗算処方方法
EP2884403A1 (en) Apparatus and method for calculating exponentiation operations and root extraction
JPS59116852A (ja) 高速除算装置
JPH0251732A (ja) 浮動小数点演算器
JP2753922B2 (ja) 固定小数点除算方法
JPH0285922A (ja) 演算回路
JPS58155456A (ja) 情報処理装置
JPH06168105A (ja) 整数除算方式