JP2004178188A - Calculation method, square root calculation method, power root calculation method, power calculation method and g/h-power calculation method - Google Patents
Calculation method, square root calculation method, power root calculation method, power calculation method and g/h-power calculation method Download PDFInfo
- Publication number
- JP2004178188A JP2004178188A JP2002342406A JP2002342406A JP2004178188A JP 2004178188 A JP2004178188 A JP 2004178188A JP 2002342406 A JP2002342406 A JP 2002342406A JP 2002342406 A JP2002342406 A JP 2002342406A JP 2004178188 A JP2004178188 A JP 2004178188A
- Authority
- JP
- Japan
- Prior art keywords
- predetermined number
- power
- constant
- binary
- bit shift
- 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.)
- Withdrawn
Links
- 238000004364 calculation method Methods 0.000 title claims abstract description 71
- 238000000034 method Methods 0.000 claims description 45
- 230000014509 gene expression Effects 0.000 description 28
- 238000010586 diagram Methods 0.000 description 4
- 238000007796 conventional method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Landscapes
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
Description
【0001】
【発明の属する技術分野】
本発明は、容易に実装することのできる演算方法、平方根演算方法、累乗根演算方法、累乗演算方法及びg/h乗演算方法に関する。
【0002】
【従来の技術】
近年、ハードワイヤードロジック等の回路を用いて様々な計算を行うことが増えてきた。
【0003】
例えば、ニュートン法を用いて所定の数の平方根を求める場合の計算方法を説明する。
【0004】
まず、図12に示すように、以下のような式1で示した曲線lを考える。
【0005】
【数1】
この式1の両辺を微分すると、以下の式2のようになる。
【0006】
【数2】
ここで、図12において、(x0, 0)、(x1, 0)、(x0, y(x0))を頂点とする三角形に注目すると、以下のような式3を得ることができる。
【0007】
【数3】
式3を参照して、x1について解くと、式4の様になる。
【0008】
【数4】
これを、xnについて一般化すると、式5の様になる。
【0009】
【数5】
即ち、所定の数の平方根を求める場合、式5の除算の計算を、繰り返しを行わなければならない。
【0010】
この様に、ニュートン法で所定の数の平方根を求める場合、除算と繰り返し処理が必要となり、ハードワイヤードロジックでの実装が難しくなる。
【0011】
例えば、平方根を演算する装置として、1回の開平演算ステップで被開平数を4ビットずつ除算して2ビットの平方根を算出し、n/2クロックでn桁の平方根を得るものがある(例えば、特許文献1。)。
【0012】
一方、1クロックで一つの計算を行うハードワイヤードロジックを実装することにより、より簡易に素早く計算を行うことが求められている。
【0013】
【特許文献1】
特開平10−78981
【0014】
【発明が解決しようとする課題】
しかし、ハードワイヤードロジックで平方根の計算を実装するために、計算された平方根を記録したテーブルを参照する方法を挙げることができる。この方法では、演算速度は高速になる。しかし、予想される入力値のダイナミックレンジの大きさだけメモリ量が必要になるので、用意しなければならないメモリ量が莫大に大きくなってしまう。
【0015】
従って、本発明の目的は、容易に実装することのできる演算方法、平方根演算方法、累乗根演算方法、累乗演算方法及びg/h乗演算方法を提供することである。
【0016】
【課題を解決するための手段】
上記課題を解決するために、本発明の第1の特徴は、所定の数を、近似して演算する演算方法に関する。即ち、本発明の第1の特徴に係る演算方法は、所定の数を2進数表記に変換するステップと、2進数表記された所定の数の属性に応じて決定される定数を取得するステップと、2進数表記された所定の数の属性に応じて決定されるビットシフト量を取得するステップと、定数を、取得したビットシフト量のビットシフトを実行するステップと、ビットシフトを実行した定数を、所定の数の演算結果として出力するステップとを備える。
【0017】
ここで、本発明の第1の特徴に係る演算方法で行う演算は、所定の数の平方根、累乗根、累乗、g/h乗(g及びhは整数)などの計算のことである。
【0018】
本発明の第1の特徴に係る演算方法によれば、所定の数を2進数表記で表し、そのビットパターンや桁数などの、2進数表記された所定の数の属性に応じて、定数を取得し、その定数をビットシフトすることにより、所定の数の演算結果の近似値を得ることができる。定数をビットシフトするので、煩雑な計算を行うことなく、演算結果を取得することができる。
【0019】
本発明の第2の特徴は、所定の数の平方根を、近似して演算する平方根演算方法に関する。即ち、本発明の第2の特徴に係る平方根演算方法は、所定の数が整数の場合、所定の数を2進数表記に変換するステップと、2進数表記された所定の数の桁数を算出するステップと、2進数表記された所定の数の上位2番目のビットから、所定の有効数字の桁数までの2進数の組み合わせと、算出された前記所定の数の桁数を2で割った余りの数と、に応じて決定された定数を取得するステップと、2進数表記された所定の数の桁数に応じて決定される、ビットシフト量を取得するステップと、定数を、取得したビットシフト量のビットシフトを実行するステップと、ビットシフトを実行した定数を、所定の数の平方根として出力するステップとを備える。
【0020】
本発明の第2の特徴に係る平方根演算方法によれば、予め有効桁数を決めて、2進数で示した有効数字の数字パターンに対応づけた定数を取得し、その定数を使って平方根の値を近似することにより、簡単な回路で、平方根の算出を実現することができる。
【0021】
ここで更に、所定の数が小数の場合、所定の数を2進数表記に変換するステップにおいて、所定の数が整数になるように、所定の数を乗数で乗して、乗した所定の数を2進数表記に変換し、所定の数の平方根として出力するステップにおいて、ビットシフトを実行した定数を、乗数の平方根で除して、所定の数の平方根として出力することが好ましい。
【0022】
これにより、小数を含む数の場合も、同様の方法で算出することができる。
【0023】
本発明の第3の特徴は、所定の数の累乗根を、近似して演算する累乗根演算方法に関する。即ち、本発明の第3の特徴に係る累乗根演算方法は、所定の数が整数の場合、所定の数を2進数表記に変換するステップと、2進数表記された所定の数の桁数を算出するステップと、2進数表記された所定の数の上位2番目のビットから、所定の有効数字の桁数までの、2進数の組み合わせと、累乗根の累乗根数と、算出された前記所定の数の桁数を累乗根の累乗根数で割った余りの数と、に応じて決定された定数を取得するステップと、2進数表記された所定の数の桁数と累乗根数に応じて決定される、ビットシフト量を取得するステップと、定数を、取得したビットシフト量のビットシフトを実行するステップと、ビットシフトを実行した定数を、所定の数の累乗根として出力するステップとを備える。
【0024】
本発明の第3の特徴に係る累乗根演算方法は、本発明の第2の特徴に係る平方根演算方法と同様の方法で、簡単な回路で累乗根の算出を実現することができる。
【0025】
ここで更に、所定の数が小数の場合、所定の数を2進数表記に変換するステップにおいて、所定の数が整数になるように、所定の数を乗数で乗して、乗した所定の数を2進数表記に変換し、所定の数の累乗根として出力するステップにおいて、ビットシフトを実行した定数を、乗数の累乗根で除して、所定の数の累乗根として出力することが好ましい。
【0026】
これにより、小数を含む数の場合も、同様の方法で算出することができる。
【0027】
本発明の第4の特徴は、所定の数の累乗を、近似して演算する累乗演算方法に関する。即ち、本発明の第4の特徴に係る累乗演算方法は、所定の数が整数の場合、所定の数を2進数表記に変換するステップと、2進数表記された所定の数の桁数を算出するステップと、2進数表記された所定の数の上位2番目のビットから、所定の有効数字の桁数までの、2進数の組み合わせと、累乗の累乗数に応じて決定された定数を取得するステップと、2進数表記された所定の数の桁数と累乗数と、に応じて決定される、ビットシフト量を取得するステップと、定数を、取得したビットシフト量のビットシフトを実行するステップと、ビットシフトを実行した定数を、所定の数の累乗として出力するステップとを備える。
【0028】
本発明の第4の特徴に係る累乗根演算方法は、本発明の第2の特徴に係る平方根演算方法と同様の方法で、簡単な回路で累乗の算出を実現することができる。
【0029】
ここで更に、所定の数が小数の場合、所定の数を2進数表記に変換するステップにおいて、所定の数が整数になるように、所定の数を乗数で乗して、乗した所定の数を2進数表記に変換し、所定の数の累乗として出力するステップにおいて、ビットシフトを実行した定数を、乗数の累乗で除して、所定の数の累乗として出力することが好ましい。
【0030】
これにより、小数を含む数の場合も、同様の方法で算出することができる。
【0031】
本発明の第5の特徴は、所定の数のg/h乗(g、hは整数)を、近似して演算するg/h乗演算方法に関する。即ち、本発明の第5の特徴に係るg/h乗演算方法は、前記所定の数が整数の場合、前記所定の数を2進数表記に変換するステップと、2進数表記された前記所定の数の桁数を算出するステップと、前記2進数表記された前記所定の数の上位2番目のビットから、所定の有効数字の桁数までの2進数の組み合わせと、前記gと、前記hと、算出された前記所定の数の桁数を前記hで割った余りの数と、に応じて決定された定数を取得するステップと、前記2進数表記された前記所定の数の桁数と前記累乗数に応じて決定される、ビットシフト量を取得するステップと、前記定数を、取得した前記ビットシフト量のビットシフトを実行するステップと、前記ビットシフトを実行した前記定数を、前記所定の数の累乗として出力するステップとを備える。
【0032】
本発明の第5の特徴に係るg/h乗演算方法は、本発明の第2の特徴に係る平方根演算方法と同様の方法で、簡単な回路でg/h乗の算出を実現することができる。
【0033】
ここで更に、前記所定の数が小数の場合、前記所定の数を2進数表記に変換するステップにおいて、前記所定の数が整数になるように、前記所定の数を乗数で乗して、乗した前記所定の数を2進数表記に変換し、前記所定の数の累乗として出力するステップにおいて、前記ビットシフトを実行した前記定数を、前記乗数のg/h乗で除して、前記所定の数のg/h乗として出力するのが好ましい。
【0034】
これにより、小数を含む数の場合も、同様の方法で算出することができる。
【0035】
【発明の実施の形態】
次に、図面を参照して、本発明の最良の実施の形態を説明する。以下の図面の記載において、同一又は類似の部分には同一又は類似の符号を付している。ただし、システム構成を示すブロック図等は模式的なものである。
【0036】
(第1の実施の形態)
本発明の第1の実施の形態においては、整数aの平方根を計算する場合について説明する。
【0037】
図1を参照して、本発明の第1の実施の形態について説明する。
【0038】
本発明の第1の実施の形態に係る演算装置1は、入力装置11、出力装置12、定数テーブル記憶装置13、0判定手段21、2進数表記手段22、桁数算出手段23、ビットシフト量算出手段24、テーブルインデックス取得手段25、定数取得手段26、ビットシフト実行手段27を備えている。
【0039】
入力装置11は、平方根演算装置の入力部分であり、平方根を求める数aを入力する装置である。出力装置12は、平方根演算装置の出力部分であり、求めた数aの平方根を出力する装置である。
【0040】
0判定手段21は、入力装置11から入力された数値が0であるか否か、判定する手段である。0である場合、0判定手段21は、出力装置12に0を出力する。0でない場合、0判定手段21は、入力装置11から入力された数aを2進数表記手段22に入力する。
【0041】
2進数表記手段22においては、0判定手段21から入力された数aを2進数表記に変換する。
【0042】
ここで、入力された数aを2進数表記に変換した場合の桁数をkとすると、式6の様に表すことができる。
【0043】
【数6】
ここで、qiは、0及び1のいずれか一つの値をとる。式6の右辺を2k−1でくくると、式7の様になる。
【0044】
【数7】
更に、式7の両辺の平方根をとると、式8の様になる。
【0045】
【数8】
ここで、式8を、kの値により、以下のように場合分けすると、式9及び式10で示すことができる。
【0046】
【数9】
【数10】
更に、上記の式9及び式10について、上位3桁を有効桁数として、残りの項を無視する近似を行うと、以下のような式11及び式12を取得することができる。
【0047】
【数11】
【数12】
定数テーブル記憶装置13は、式11及び式12のbの値が格納されている。
【0048】
即ち、定数テーブル記憶装置13は、2進数表記された所定の数(a)の上位2番目のビットから、所定の有効数字の桁数までの2進数の組み合わせと、算出された所定の数(a)の桁数を2で割った余りの数に応じて決定された定数が格納されている。例えば、有効数字の桁数が3ビットの場合は、上位1ビットは必ず「1」になるので、上位2番目のビットと3番目のビットの2進数の組み合わせに対応して、それぞれ定数が格納されている。
【0049】
具体的には、図2(a)に示したkが奇数の場合の定数と、図2(b)に示したkが偶数の場合の定数は、それぞれ、上位2番目のビットと3番目のビットの組み合わせが、「00」、「01」、「10」、「11」について決定された定数が、定数テーブル記憶装置13に格納されている。
【0050】
例えば、kが奇数で、上位2番目のビットと3番目のビットの組み合わせが「01」の場合、1+1/4=1.25の平方根の2進数表記の近似値が、定数として登録されている。
【0051】
桁数算出手段23は、2進数表記されたaの桁数kを算出する手段である。
【0052】
ビットシフト量算出手段24は、定数テーブル記憶装置13に登録された定数を左シフトするビットシフト量sを算出する手段である。ビットシフト量は、桁数算出手段23で求められた桁数kが奇数の場合、s=(k−1)/2で、桁数kが偶数の場合、s=(k−2)/2として算出される。
【0053】
テーブルインデックス取得手段25は、定数テーブル記憶装置13から取得する定数のテーブルインデックスiを求める手段である。具体的には、有効桁数が3桁の場合、2進数表記されたaをk−3だけ右ビットシフトする。これにより、3桁の2進数表記の数値を得ることができる。ここで、iは、この3桁の2進数表記の数値の下位2ビットの組み合わせで求めることができる。
【0054】
定数取得手段26は、定数テーブル記憶装置13を参照する手段である。テーブルインデックス取得手段25で取得したテーブルインデックスiと、桁数算出手段23算出したkの値に相当する定数bを、定数テーブル記憶装置13から取得する。
【0055】
ビットシフト実行手段27は、定数取得手段26で取得した定数bを、ビットシフト量算出手段24で取得した左ビットシフト量sの値だけ左ビットシフトして、aの平方根の出力値を求める手段である。
【0056】
次に、図3を参照して、本発明の第1の実施の形態に係る演算方法について説明する。
【0057】
まず、ステップS101において、入力装置11により、10進数表記されたaの値を取得する。次に、ステップS102において、0判定手段21により、aが0か否かを判定する。aが0の場合、ステップS103において、Xに0を代入し、ステップS108において、Xを出力する。
【0058】
一方、ステップS102において、aが0でない場合、ステップS104において、2進数表記手段22により、10進数表記されたaを2進数表記に変換する。
【0059】
次、ステップS105において、桁数算出手段23及びビットシフト量算出手段24により、2進数表記されたaの桁数から、左ビットシフト量を算出する。更に、ステップS106において、テーブルインデックス取得手段25及び定数取得手段26により、2進数表記で示されたaに対応する定数を、定数テーブル記憶装置13から取得する。
【0060】
更に、ステップS107において、ビットシフト実行手段27によって、ステップS106で取得した定数を、ステップS105で算出した左ビットシフト量だけ、左ビットシフトを実行し、Xに代入する。更に、ステップS108において、出力装置12によって、Xを出力する。
【0061】
図4を参照して、本発明の実施の形態によって近似して得られた結果と、本来の値とを比較する。3bitのラインは有効桁数を3桁として、6ビットのラインは有効桁数を6桁として、得られた結果である。この様に、本発明の実施の形態に係る演算方法は、高い精度を必要としない場合に、有効である。
【0062】
又、有効桁数を多くすることにより、より本来の値に近づけることができる。従って、要求される制度に従って有効桁数を設定することにより、効率よく演算することができる。
【0063】
(第2の実施の形態)
本発明の第1の実施の形態の変形例として、図5を参照して、本発明の第2の実施の形態を説明する。
【0064】
本発明の第2の実施の形態に係る演算装置1は、本発明の第1の実施の形態に係る演算装置1に比べて、0判定手段21を備えていない点が異なる。本発明の第2の実施の形態においては、桁数算出手段23において、桁数が0である場合、入力されたaが0であることを判定し、出力装置12に0を出力する。
【0065】
図6を参照して、本発明の第2の実施の形態に係る演算方法を説明する。
【0066】
まず、ステップS201において、入力装置11により、10進数表記されたaの値を取得する。次に、ステップS202において、2進数表記手段22により、10進数表記されたaを2進数表記に変換する。
【0067】
次に、ステップS203において、桁数算出手段23によって、2進数表記されたaの桁数が0か否かを判定する。aの桁数が0の場合、ステップS204において、Xに0を代入し、ステップS208において、Xを出力する。
【0068】
一方、ステップS203において、aの桁数が0でない場合、ステップS205において、桁数算出手段23及びビットシフト量算出手段24により、2進数表記されたaの桁数から、左ビットシフト量を算出する。次に、ステップS206において、テーブルインデックス取得手段25及び定数取得手段26により、2進数表記で示されたaに対応する定数を、定数テーブル記憶装置13から取得する。
【0069】
更に、ステップS207において、ビットシフト実行手段27によって、ステップS206で取得した定数を、ステップS205で算出した左ビットシフト量だけ、左ビットシフトを実行し、Xに代入する。更に、ステップS208において、出力装置12によって、Xを出力する。
【0070】
この様に、本発明の第2の実施の形態においては、本発明の第1の実施の形態に比べて簡略な構成で、同様の演算を行うことができる。
【0071】
(第3の実施の形態)
本発明の第3の実施の形態においては、数aの累乗根(n乗根)を計算する場合、特に数aの3乗根を計算する場合について説明する。
【0072】
図7を参照して、本発明の第3の実施の形態について説明する。
【0073】
本発明の第3の実施の形態に係る演算装置1は、本発明の第1の実施の形態に係る演算装置1と比べて、0判定手段21の代わりに、数値判定手段28を備えている点が異なる。
【0074】
数値判定手段28は、入力装置11から入力された数値aについて判定する。第1及び第2の実施の形態においては、aが整数の場合について説明したが、第3の実施の形態においては、aが整数でなくても良い。数値判定手段28は、数値aが0の場合、0判定手段21と同様に、0を出力装置12に出力する。又、数値aが小数点を含む数値の場合は、数値aに乗算して、整数にする。このとき、例えば、10u n倍(uは整数)して、aを整数にするのがより好ましい、この場合、ビットシフト実行手段27で、1/10uして、結果を出せば良く、桁をずらすだけで、計算を行うことができる。
【0075】
ビットシフト量算出手段24は、定数テーブル記憶装置13に登録された定数を左シフトするビットシフト量sを算出する手段である。ビットシフト量は、桁数算出手段23で求められた桁数kがk=nm+i(mは整数、iは1〜n−1の整数)の場合、s=(k−i)/nで、桁数kがk=nm(mは整数)の場合、s=(k−n)/nとして算出される。
【0076】
次に、一般化したn乗根を算出する場合の定数テーブル記憶装置13に格納される定数について説明する。
【0077】
2進数表記手段22によって得られる2進数表記は、入力された数aを2進数表記に変換した場合の桁数をkとすると、式13の様に表すことができる。
【0078】
【数13】
ここで、qiは、0及び1のいずれか一つの値をとる。式13の右辺を2k−1でくくると、式14の様になる。
【0079】
【数14】
更に、式14の両辺のn乗根をとると、式15の様になる。
【0080】
【数15】
ここで、式15を、kの値により、以下のように場合分けすると、式16及び式17で示すことができる。
【0081】
【数16】
【数17】
更に、上記の式16及び式17について、上位3桁を有効桁数として、残りの項を無視する近似を行うと、第1の実施の形態と同様に演算を行うことができる。
【0082】
例えば、有効桁数を3桁として3乗根を計算する場合について説明すると、図8(a)に示したk=3m+1の場合の定数と、図8(b)に示したk=3m+2の場合の定数と、図8(c)に示したk=3mの場合の定数は、それぞれ、上位2番目のビットと3番目のビットの組み合わせが、「00」、「01」、「10」、「11」について決定された定数が、定数テーブル記憶装置13に格納されている。
【0083】
例えば、kが3m+1で、上位2番目のビットと3番目のビットの組み合わせが「01」の場合、1+1/4=1.25の3乗根の2進数表記の近似値が、定数として登録されている。
【0084】
第3の実施の形態においては、上記の様な定数が格納された定数テーブル記憶装置13を用いと、ビットシフト量算出手段24と、を用いて第1の実施の形態と同様の計算を行うと、所定の数の3乗根を得ることができる。
【0085】
次に、図9を参照して、本発明の第3の実施の形態に係る演算方法について説明する。
【0086】
まず、ステップS301において、入力装置11により、10進数表記されたaの値を取得する。次に、ステップS302において、数値判定手段28により、aが0か否かを判定する。aが0の場合、ステップS303において、Xに0を代入し、ステップS314において、出力装置12にXを出力する。
【0087】
一方、ステップS302において、aが0でない場合、更に、ステップS304において、10進数表記されたaが、整数であるか否かを判定する。整数である場合、ステップS306において、cにaを代入する。又、整数でない場合、ステップS305において、10進数表記されたaを、整数になるように10u n倍して、cに代入する。
【0088】
次に、ステップS307において、2進数表記手段22により、10進数表記されたcを2進数表記に変換する。次に、ステップS308において、桁数算出手段23及びビットシフト量算出手段24により、2進数表記されたcの桁数から、左ビットシフト量を算出する。更に、ステップS309において、テーブルインデックス取得手段25及び定数取得手段26により、2進数表記で示されたcに対応する定数を、定数テーブル記憶装置13から取得する。
【0089】
更に、ステップS310において、ビットシフト実行手段27によって、ステップS309で取得した定数を、ステップS308で算出した左ビットシフト量だけ、左ビットシフトを実行し、Yに代入する。
【0090】
次に、ステップS311において、入力されたaが整数であるか否かを判定する。aが整数である場合、ステップS313において、XにYを代入して、ステップS314において、出力装置12にXを出力する。一方、aが整数でない場合、ステップS312において、Yを1/10u倍した値をXに代入して、ステップS314において、出力装置12にXを出力する。
【0091】
第3の実施の形態によれば、整数に限らず、小数を含む数の累乗根を求めることができる。更に、平方根の算出も、定数テーブル記憶装置13に登録する定数と、ビットシフト量算出手段24の計算方法を変更するだけで、第1の実施の形態と同様の方法で求めることができる。
【0092】
(第4の実施の形態)
本発明の第4の実施の形態においては、数aの累乗(n乗)を計算する場合について説明する。
【0093】
第4の実施の形態においては、第3の実施の形態と同様に定数テーブル記憶装置13と、ビットシフト量算出手段24の計算方法を変更することにより、数aの累乗を計算することができる。
【0094】
次に、一般化したn乗を算出する場合の定数テーブル記憶装置13に格納される定数について説明する。
【0095】
2進数表記手段22によって得られる2進数表記は、入力された数aを2進数表記に変換した場合の桁数をkとすると、式13の様に表すことができる。ここで、qiは、0及び1のいずれか一つの値をとる。式13の右辺を2k−1でくくると、式14の様になる。
【0096】
更に、式14の両辺のn乗をとると、式18の様になる。
【0097】
【数18】
ここで、式18は、式19の様に示すことができる。
【0098】
【数19】
更に、上記の式19について、上位3桁を有効桁数として、残りの項を無視する近似を行うと、第1の実施の形態と同様に演算を行うことができる。
【0099】
例えば、有効桁数を3桁として3乗を計算する場合について説明すると、図10を参照するように、上位2番目のビットと3番目のビットの組み合わせが、「00」、「01」、「10」、「11」について決定された定数が、定数テーブル記憶装置13に格納されている。
【0100】
例えば、上位2番目のビットと3番目のビットの組み合わせが「01」の場合、1+1/4=1.25の3乗の2進数表記の近似値が、定数として登録されている。
【0101】
ここで、第4の実施の形態に係るビットシフト量算出手段24において、ビットシフト量を計算する場合、ビットシフト量sは、桁数算出手段23で求められた桁数kからs=(k−1)*nと算出される。
【0102】
第4の実施の形態によれば、n乗の算出も、定数テーブル記憶装置13に登録する定数と、ビットシフト量算出手段24での計算方法と、を変更するだけで、第1の実施の形態と同様の方法で求めることができる。
【0103】
(第5の実施の形態)
本発明の第5の実施の形態においては、数aのg/h乗(g、hは整数)を計算する場合、特に、2/3乗を計算する場合について説明する。
【0104】
第5の実施の形態においては、第3の実施の形態と同様に、定数テーブル記憶装置13と、ビットシフト量算出手段24を変更することにより、数aのg/h乗を計算することができる。
【0105】
次に、一般化したg/h乗を算出する場合の定数テーブル記憶装置13に格納された定数について説明する。
【0106】
2進数表記手段22によって得られる2進数表記は、入力された数aを2進数表記に変換した場合の桁数をkとすると、式13の用に表すことができる。
【0107】
ここで、qiは、0及び1のいずれか一つの値をとる。式13の右辺を2k−1でくくると、式14の様になる。
【0108】
更に、式14の両辺のg/h乗をとると、式20の様になる。
【0109】
【数20】
ここで、式20を、kの値により場合分けすると、式21及び式22で示すことができる。
【0110】
【数21】
【数22】
更に、上記の式21及び式22について、上位3桁を有効桁数として、残りの項を無視する近似を行うと、第1の実施の形態と同様に演算を行うことができる。
【0111】
例えば、有効桁数を3桁として2/3乗を計算する場合について説明すると、図11(a)に示したk=3m+1の場合の定数と、図11(b)に示したk=3m+2の場合の定数と、図11(c)に示したk=3mの場合の定数は、それぞれ、上位2番目のビットと3番目のビットの組み合わせが、「00」、「01」、「10」、「11」について決定された定数が、定数テーブル記憶装置13に格納されている。
【0112】
例えば、kが3m+1で、上位2番目のビットと3番目のビットの組み合わせが「01」の場合、1+1/4=1.25の2/3乗の2進数表記の近似値が、定数として登録されている。
【0113】
第5の実施の形態におけるビットシフト量算出手段24は、桁数算出手段23で求められた桁数kがk=hm+i(mは整数、iは1〜n−1の整数)の場合、s=(k−i)*g/hで、k=hm(mは整数)の場合、s=(k−h)*g/hとして算出される。
【0114】
第5の実施の形態によれば、g/h乗の算出も、定数テーブル記憶装置13に登録する定数と、ビットシフト量算出手段24での計算方法と、を変更するだけで、第1の実施の形態と同様の方法で求めることができる。
【0115】
(その他の実施の形態)
上記のように、本発明の実施の形態によって記載したが、この開示の一部をなす論述及び図面はこの発明を限定するものであると理解すべきではない。この開示から当業者には様々な代替実施の形態、実施例及び運用技術が明らかとなろう。
【0116】
本発明の第1乃至第5の実施の形態を別々に記載したが、定数テーブル記憶装置に、平方根、3乗根、4乗根、3乗、4乗などの様々な演算に必要な定数を格納することにより、同様の演算回路で、これら全ての演算を行うことができる。
【0117】
この様に、本発明はここでは記載していない様々な実施の形態等を含むことは勿論である。従って、本発明の技術的範囲は上記の説明から妥当な特許請求の範囲に係る発明特定事項によってのみ定められるものである。
【0118】
【発明の効果】
本発明によれば、容易に実装することのできる演算方法、平方根演算方法、累乗根演算方法、累乗演算方法及びg/h乗演算方法を提供することができる。
【図面の簡単な説明】
【図1】本発明の第1の実施の形態に係る演算装置の機能ブロック図である。
【図2】本発明の第1の実施の形態に係る演算装置に備えられた定数テーブル記憶装置のデータ項目とデータの例である。
【図3】本発明の第1の実施の形態に係る演算方法を示したフローチャートである。
【図4】本発明の第1の実施の形態によって近似して得られた結果と、本来の値とを比較したグラフである。
【図5】本発明の第2の実施の形態に係る演算装置の機能ブロック図である。
【図6】本発明の第2の実施の形態に係る演算方法を示したフローチャートである。
【図7】本発明の第3の実施の形態に係る演算装置の機能ブロック図である。
【図8】本発明の第3の実施の形態に係る演算装置に備えられた定数テーブル記憶装置のデータ項目とデータの例である。
【図9】本発明の第3の実施の形態に係る演算方法を示したフローチャートである。
【図10】本発明の第4の実施の形態に係る演算装置に備えられた定数テーブル記憶装置のデータ項目とデータの例である。
【図11】本発明の第5の実施の形態に係る演算装置に備えられた定数テーブル記憶装置のデータ項目とデータの例である。
【図12】従来の平方根を演算する方法を説明したグラフである。
【符号の説明】
1…演算装置
11…入力装置
12…出力装置
13…定数テーブル記憶装置
21…0判定手段
22…2進数表記手段
23…桁数算出手段
24…ビットシフト量算出手段
25…テーブルインデックス取得手段
26…定数取得手段
27…ビットシフト実行手段
28…数値判定手段[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to an operation method, a square root operation method, a power root operation method, a power operation method, and a g / h power operation method that can be easily implemented.
[0002]
[Prior art]
In recent years, various calculations using circuits such as hard-wired logic have increased.
[0003]
For example, a calculation method when a predetermined number of square roots is obtained using the Newton method will be described.
[0004]
First, as shown in FIG. 12, consider a
[0005]
(Equation 1)
Differentiating both sides of
[0006]
(Equation 2)
Here, in FIG. 12, when attention is paid to a triangle having vertices of (x0, 0), (x1, 0), and (x0, y (x0)), the following
[0007]
(Equation 3)
Referring to
[0008]
(Equation 4)
When this is generalized for xn, Equation 5 is obtained.
[0009]
(Equation 5)
That is, when calculating the square root of a predetermined number, the calculation of the division of Equation 5 must be repeated.
[0010]
As described above, when a square root of a predetermined number is obtained by the Newton method, division and repetition processing are required, and implementation with hard-wired logic becomes difficult.
[0011]
For example, as a device for calculating a square root, there is a device that calculates a square root of 2 bits by dividing a square root to be squared by 4 bits in one square root calculation step and obtains a square root of n digits by n / 2 clocks (for example, ,
[0012]
On the other hand, there is a demand for a simpler and faster calculation by mounting a hard wired logic that performs one calculation in one clock.
[0013]
[Patent Document 1]
JP-A-10-78981
[0014]
[Problems to be solved by the invention]
However, in order to implement the calculation of the square root in the hard-wired logic, there can be mentioned a method of referring to a table recording the calculated square root. In this method, the calculation speed becomes high. However, since a memory amount is required corresponding to the expected dynamic range of the input value, the memory amount to be prepared becomes enormous.
[0015]
Accordingly, an object of the present invention is to provide an operation method, a square root operation method, a power root operation method, a power operation method, and a g / h power operation method that can be easily implemented.
[0016]
[Means for Solving the Problems]
In order to solve the above-described problem, a first feature of the present invention relates to a calculation method for calculating a predetermined number by approximation. That is, the operation method according to the first aspect of the present invention includes a step of converting a predetermined number into a binary number, and a step of obtaining a constant determined according to an attribute of the predetermined number in the binary number. Acquiring a bit shift amount determined according to a predetermined number of attributes represented in binary, a constant to execute the bit shift of the acquired bit shift amount, and a constant to execute the bit shift. And outputting the result as a predetermined number of calculation results.
[0017]
Here, the calculation performed by the calculation method according to the first aspect of the present invention is a calculation such as a square root, a power root, a power, or a g / h power (g and h are integers) of a predetermined number.
[0018]
According to the arithmetic method according to the first aspect of the present invention, a predetermined number is represented in binary notation, and a constant is represented according to an attribute of the predetermined number represented in binary notation, such as its bit pattern and the number of digits. By obtaining and shifting the constant by a bit, an approximate value of a predetermined number of calculation results can be obtained. Since the constant is bit-shifted, the operation result can be obtained without performing complicated calculations.
[0019]
A second feature of the present invention relates to a square root calculation method for calculating a predetermined number of square roots by approximation. That is, in the square root calculation method according to the second aspect of the present invention, when the predetermined number is an integer, the predetermined number is converted to a binary number, and the number of digits of the predetermined number is calculated. And a combination of a binary number from the second most significant bit of the predetermined number represented by the binary number to a predetermined number of significant digits, and dividing the calculated number of digits of the predetermined number by two. The step of obtaining a constant determined according to the number of remainders, the step of obtaining a bit shift amount determined according to the predetermined number of digits in a binary number, and the step of obtaining a constant. The method includes a step of performing a bit shift of a bit shift amount and a step of outputting a constant obtained by performing the bit shift as a square root of a predetermined number.
[0020]
According to the square root calculation method according to the second aspect of the present invention, the number of significant digits is determined in advance, a constant corresponding to the number pattern of significant digits represented by a binary number is obtained, and the square root is calculated using the constant. By approximating the values, the calculation of the square root can be realized with a simple circuit.
[0021]
Further, when the predetermined number is a decimal number, in the step of converting the predetermined number into a binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number becomes an integer, and the predetermined number raised to the power is multiplied. Is converted to binary notation, and in the step of outputting as a square root of a predetermined number, it is preferable that the constant subjected to the bit shift is divided by a square root of a multiplier and output as a square root of a predetermined number.
[0022]
Thereby, even in the case of a number including a decimal number, it can be calculated by the same method.
[0023]
A third feature of the present invention relates to a method for calculating a power root that approximates a predetermined number of power roots. That is, in the power root calculating method according to the third aspect of the present invention, when the predetermined number is an integer, the predetermined number is converted into a binary number, and the number of digits of the predetermined number in the binary number is converted. Calculating, the combination of binary numbers from the second most significant bit of the predetermined number expressed in binary number to the number of significant digits, the number of power roots of power root, and the calculated predetermined number Obtaining the constant determined according to the number of digits obtained by dividing the number of digits of the number by the number of powers of the power root, and the number of digits and the number of powers of the predetermined number expressed in binary notation Obtaining a bit shift amount determined by the step; a step of performing a bit shift of the obtained bit shift amount; and a step of outputting the bit shifted constant as a root of a predetermined number. Is provided.
[0024]
The method for calculating the power root according to the third aspect of the present invention can realize the calculation of the power root with a simple circuit in the same manner as the method for calculating the square root according to the second aspect of the present invention.
[0025]
Further, when the predetermined number is a decimal number, in the step of converting the predetermined number into a binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number becomes an integer, and the predetermined number raised to the power is multiplied. Is converted to binary notation, and in the step of outputting as a root of a predetermined number, it is preferable that the constant subjected to the bit shift is divided by the root of the multiplier to output as a root of a predetermined number.
[0026]
Thereby, even in the case of a number including a decimal number, it can be calculated by the same method.
[0027]
A fourth feature of the present invention relates to a power calculation method for calculating a power of a predetermined number by approximation. That is, in the power operation method according to the fourth aspect of the present invention, when the predetermined number is an integer, the predetermined number is converted into a binary number, and the number of digits of the predetermined number is calculated. And obtaining a constant determined according to the combination of binary numbers from the second most significant bit of the predetermined number represented in binary number to the number of significant digits and the power of the power. A step of obtaining a bit shift amount determined according to a predetermined number of digits and a power of a predetermined number expressed in a binary number, and a step of performing a bit shift of a constant by the obtained bit shift amount. And outputting the constant after the bit shift as a power of a predetermined number.
[0028]
The method for calculating the power root according to the fourth aspect of the present invention can realize the calculation of the power with a simple circuit in the same manner as the method for calculating the square root according to the second aspect of the present invention.
[0029]
Further, when the predetermined number is a decimal number, in the step of converting the predetermined number into a binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number becomes an integer, and the predetermined number raised to the power is multiplied. Is converted into a binary number notation, and in the step of outputting as a power of a predetermined number, it is preferable that the constant subjected to the bit shift is divided by the power of the multiplier to output as a power of the predetermined number.
[0030]
Thereby, even in the case of a number including a decimal number, it can be calculated by the same method.
[0031]
A fifth feature of the present invention relates to a g / h power calculation method for calculating a predetermined number of g / h powers (g and h are integers) by approximation. That is, in the g / h-th power calculation method according to a fifth aspect of the present invention, when the predetermined number is an integer, the predetermined number is converted into a binary notation, and Calculating the number of digits of a number, a combination of binary numbers from the second most significant bit of the predetermined number represented by the binary number to a predetermined number of significant digits, the g, the h, Obtaining a constant determined according to the number of digits obtained by dividing the calculated number of digits of the predetermined number by the h, and the number of digits of the predetermined number represented by the binary number and the number of digits. A step of obtaining a bit shift amount, which is determined according to a power, a step of performing the bit shift of the obtained bit shift amount, and a step of Outputting as a power of a number Obtain.
[0032]
The g / h power calculation method according to the fifth aspect of the present invention is capable of realizing the g / h power calculation with a simple circuit in the same manner as the square root operation method according to the second feature of the present invention. it can.
[0033]
Here, when the predetermined number is a decimal number, in the step of converting the predetermined number to a binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number becomes an integer. Converting the predetermined number into binary notation and outputting the result as a power of the predetermined number, dividing the constant subjected to the bit shift by a g / h power of the multiplier to obtain the predetermined number. It is preferable to output the number as the g / h power.
[0034]
Thereby, even in the case of a number including a decimal number, it can be calculated by the same method.
[0035]
BEST MODE FOR CARRYING OUT THE INVENTION
Next, the best embodiment of the present invention will be described with reference to the drawings. In the following description of the drawings, the same or similar parts are denoted by the same or similar reference numerals. However, the block diagram and the like showing the system configuration are schematic.
[0036]
(First Embodiment)
In the first embodiment of the present invention, a case where the square root of the integer a is calculated will be described.
[0037]
With reference to FIG. 1, a first embodiment of the present invention will be described.
[0038]
The
[0039]
The
[0040]
The 0
[0041]
The
[0042]
Here, assuming that the number of digits when the input number a is converted to binary notation is k, the number can be expressed as in Equation 6.
[0043]
(Equation 6)
Here, qi takes one of the
[0044]
(Equation 7)
Further, when taking the square root of both sides of Expression 7, Expression 8 is obtained.
[0045]
(Equation 8)
Here, when Expression 8 is divided into cases according to the value of k as follows, Expression 9 and
[0046]
(Equation 9)
(Equation 10)
Further, with respect to the
[0047]
(Equation 11)
(Equation 12)
The constant
[0048]
That is, the constant
[0049]
Specifically, the constant when k is an odd number shown in FIG. 2A and the constant when k is an even number shown in FIG. 2B are respectively the upper second bit and the third upper bit. Constants determined for combinations of bits “00”, “01”, “10”, and “11” are stored in the constant
[0050]
For example, if k is an odd number and the combination of the upper second bit and the third bit is “01”, the approximate value of the square root of 1 + / = 1.25 in binary notation is registered as a constant. .
[0051]
The digit number calculating means 23 is a means for calculating the digit number k of a represented in binary.
[0052]
The bit shift amount calculating means 24 is a means for calculating a bit shift amount s for shifting the constant registered in the constant
[0053]
The table
[0054]
The constant obtaining
[0055]
The bit
[0056]
Next, an arithmetic method according to the first embodiment of the present invention will be described with reference to FIG.
[0057]
First, in step S101, the
[0058]
On the other hand, if a is not 0 in step S102, a in decimal notation is converted by the binary notation means 22 into binary notation in step S104.
[0059]
Next, in step S105, the left bit shift amount is calculated by the digit
[0060]
Further, in step S107, the bit
[0061]
Referring to FIG. 4, a result obtained by approximation according to the embodiment of the present invention is compared with an original value. The 3-bit line is the result obtained when the number of significant digits is 3 digits, and the 6-bit line is the result obtained when the number of significant digits is 6 digits. As described above, the calculation method according to the embodiment of the present invention is effective when high accuracy is not required.
[0062]
Also, by increasing the number of significant digits, the value can be made closer to the original value. Therefore, by setting the number of significant digits in accordance with the required system, the calculation can be performed efficiently.
[0063]
(Second embodiment)
As a modification of the first embodiment of the present invention, a second embodiment of the present invention will be described with reference to FIG.
[0064]
The
[0065]
With reference to FIG. 6, an operation method according to the second embodiment of the present invention will be described.
[0066]
First, in step S201, the value of a expressed in decimal notation is acquired by the
[0067]
Next, in step S203, the number-of-digits calculating means 23 determines whether or not the number of digits of the binary notation a is zero. If the number of digits of a is 0, 0 is substituted for X in step S204, and X is output in step S208.
[0068]
On the other hand, if the number of digits of a is not 0 in step S203, the number of
[0069]
Further, in step S207, the bit
[0070]
Thus, in the second embodiment of the present invention, similar operations can be performed with a simpler configuration than in the first embodiment of the present invention.
[0071]
(Third embodiment)
In the third embodiment of the present invention, a description will be given of a case of calculating a power root (n-th root) of a number a, particularly a case of calculating a third root of a number a.
[0072]
The third embodiment of the present invention will be described with reference to FIG.
[0073]
The
[0074]
The numerical value determination means 28 determines the numerical value a input from the
[0075]
The bit shift amount calculating means 24 is a means for calculating a bit shift amount s for shifting the constant registered in the constant
[0076]
Next, constants stored in the constant
[0077]
The binary notation obtained by the binary notation means 22 can be expressed as in
[0078]
(Equation 13)
Here, qi takes one of the
[0079]
[Equation 14]
Further, when taking the nth root of both sides of Expression 14, Expression 15 is obtained.
[0080]
[Equation 15]
Here, Expression 15 can be expressed as Expressions 16 and 17 by dividing the expression 15 according to the value of k as follows.
[0081]
(Equation 16)
[Equation 17]
Furthermore, when the approximation of the above equations 16 and 17 is performed with the upper three digits as the number of significant digits and ignoring the remaining terms, the calculation can be performed in the same manner as in the first embodiment.
[0082]
For example, the case of calculating the cube root with three significant digits will be described. The constant for k = 3m + 1 shown in FIG. 8A and the case for k = 3m + 2 shown in FIG. And the constant for k = 3m shown in FIG. 8C, the combination of the upper second bit and the third bit is “00”, “01”, “10”, and “10”, respectively. The constant determined for “11” is stored in the constant
[0083]
For example, if k is 3m + 1 and the combination of the upper 2nd bit and the 3rd bit is “01”, the approximate value of the 3rd root of 1 + 1/4 = 1.25 in binary notation is registered as a constant. ing.
[0084]
In the third embodiment, the same calculation as in the first embodiment is performed by using the constant
[0085]
Next, an operation method according to the third embodiment of the present invention will be described with reference to FIG.
[0086]
First, in step S301, the value of a expressed in decimal notation is acquired by the
[0087]
On the other hand, if a is not 0 in step S302, it is further determined in step S304 whether a in decimal notation is an integer. If it is an integer, a is substituted for c in step S306. If it is not an integer, in step S305, a expressed in decimal notation is converted to an integer by 10u nMultiply and substitute for c.
[0088]
Next, in step S307, c in decimal notation is converted to binary notation by the binary notation means 22. Next, in step S308, the digit number calculating means 23 and the bit shift amount calculating means 24 calculate the left bit shift amount from the digit number of c represented in binary. Further, in step S309, the table
[0089]
Further, in step S310, the bit
[0090]
Next, in step S311, it is determined whether or not the input a is an integer. If a is an integer, Y is substituted for X in step S313, and X is output to the
[0091]
According to the third embodiment, not only integers but also roots of numbers including decimals can be obtained. Further, the calculation of the square root can be obtained in the same manner as in the first embodiment, only by changing the constant registered in the constant
[0092]
(Fourth embodiment)
In the fourth embodiment of the present invention, a case will be described in which a power (nth power) of the number a is calculated.
[0093]
In the fourth embodiment, the power of the number a can be calculated by changing the calculation method of the constant
[0094]
Next, constants stored in the constant
[0095]
The binary notation obtained by the binary notation means 22 can be expressed as in
[0096]
Further, when taking the n-th power of both sides of Expression 14, Expression 18 is obtained.
[0097]
(Equation 18)
Here, Expression 18 can be expressed as Expression 19.
[0098]
[Equation 19]
Further, in the above equation 19, when the upper three digits are regarded as the number of significant digits and an approximation ignoring the remaining terms is performed, the calculation can be performed in the same manner as in the first embodiment.
[0099]
For example, a case where the number of significant digits is set to three and the third power is calculated will be described. As shown in FIG. 10, the combination of the second most significant bit and the third most significant bit is “00”, “01”, “ The constants determined for “10” and “11” are stored in the constant
[0100]
For example, when the combination of the upper 2nd bit and the 3rd bit is “01”, an approximate value of a 1 / + 1 = 1.25 cubed binary number is registered as a constant.
[0101]
Here, when the bit shift amount is calculated by the bit shift amount calculating means 24 according to the fourth embodiment, the bit shift amount s is calculated from the digit number k obtained by the digit number calculating means 23 as s = (k -1) calculated as * n.
[0102]
According to the fourth embodiment, the calculation of the n-th power can be performed only by changing the constant to be registered in the constant
[0103]
(Fifth embodiment)
In the fifth embodiment of the present invention, the case where the number a is raised to the power of g / h (g and h are integers), particularly the case where the power of 2/3 is calculated, will be described.
[0104]
In the fifth embodiment, similarly to the third embodiment, the g / h power of the number a can be calculated by changing the constant
[0105]
Next, the constants stored in the constant
[0106]
The binary notation obtained by the binary notation means 22 can be expressed by
[0107]
Here, qi takes one of the
[0108]
Further, when taking the g / h power of both sides of Expression 14, Expression 20 is obtained.
[0109]
(Equation 20)
Here, when Expression 20 is divided into cases according to the value of k,
[0110]
(Equation 21)
(Equation 22)
Further, in the
[0111]
For example, the case of calculating the 2/3 power with the number of significant digits as 3 will be described. A constant for k = 3m + 1 shown in FIG. 11A and a constant for k = 3m + 2 shown in FIG. The constant in the case and the constant in the case of k = 3m shown in FIG. 11C indicate that the combination of the second and third bits is “00”, “01”, “10”, The constant determined for “11” is stored in the constant
[0112]
For example, if k is 3m + 1 and the combination of the upper 2nd bit and the 3rd bit is “01”, the approximate value in binary notation of 1 + 1/4 = 1.25 2/3 is registered as a constant. Have been.
[0113]
In the fifth embodiment, the bit shift
[0114]
According to the fifth embodiment, the calculation of the g / h power can be performed only by changing the constant registered in the constant
[0115]
(Other embodiments)
As described above, the embodiments of the present invention have been described. However, it should not be understood that the description and drawings forming a part of the present disclosure limit the present invention. From this disclosure, various alternative embodiments, examples, and operation techniques will be apparent to those skilled in the art.
[0116]
Although the first to fifth embodiments of the present invention are separately described, constants required for various operations such as square root, third root, fourth root, third power, and fourth power are stored in the constant table storage device. By storing, all of these operations can be performed by a similar operation circuit.
[0117]
As described above, the present invention naturally includes various embodiments and the like not described herein. Therefore, the technical scope of the present invention is determined only by the invention specifying matters according to the claims that are appropriate from the above description.
[0118]
【The invention's effect】
According to the present invention, it is possible to provide an operation method, a square root operation method, a power root operation method, a power operation method, and a g / h power operation method that can be easily implemented.
[Brief description of the drawings]
FIG. 1 is a functional block diagram of an arithmetic device according to a first embodiment of the present invention.
FIG. 2 is an example of data items and data in a constant table storage device provided in the arithmetic device according to the first embodiment of the present invention.
FIG. 3 is a flowchart illustrating a calculation method according to the first embodiment of the present invention.
FIG. 4 is a graph comparing results obtained by approximation according to the first embodiment of the present invention with original values.
FIG. 5 is a functional block diagram of a calculation device according to a second embodiment of the present invention.
FIG. 6 is a flowchart illustrating a calculation method according to a second embodiment of the present invention.
FIG. 7 is a functional block diagram of an arithmetic unit according to a third embodiment of the present invention.
FIG. 8 is an example of data items and data of a constant table storage device provided in an arithmetic device according to a third embodiment of the present invention.
FIG. 9 is a flowchart illustrating a calculation method according to a third embodiment of the present invention.
FIG. 10 is an example of data items and data in a constant table storage device provided in an arithmetic device according to a fourth embodiment of the present invention.
FIG. 11 is an example of data items and data in a constant table storage device provided in an arithmetic device according to a fifth embodiment of the present invention.
FIG. 12 is a graph illustrating a conventional method for calculating a square root.
[Explanation of symbols]
1 ... arithmetic unit
11 Input device
12 Output device
13. Constant table storage device
21 ... 0 determination means
22 ... Binary notation means
23 digit number calculation means
24 ... Bit shift amount calculation means
25 ... Table index acquisition means
26 ... Constant acquisition means
27 ... Bit shift executing means
28 Numerical value judgment means
Claims (9)
前記所定の数を2進数表記に変換するステップと、
2進数表記された前記所定の数の属性に応じて決定される定数を取得するステップと、
前記2進数表記された前記所定の数の属性に応じて決定されるビットシフト量を取得するステップと、
前記定数を、取得した前記ビットシフト量のビットシフトを実行するステップと、
前記ビットシフトを実行した前記定数を、前記所定の数の演算結果として出力するステップ
とを備えることを特徴とする演算方法。In a calculation method of calculating a predetermined number by approximation,
Converting the predetermined number into binary notation;
Obtaining a constant determined according to the predetermined number of attributes represented in binary;
Obtaining a bit shift amount determined according to the predetermined number of attributes represented by the binary number;
Performing the bit shift of the obtained bit shift amount with the constant,
Outputting the constant after the bit shift as the predetermined number of operation results.
前記所定の数が整数の場合、
前記所定の数を2進数表記に変換するステップと、
2進数表記された前記所定の数の桁数を算出するステップと、
前記2進数表記された前記所定の数の上位2番目のビットから、所定の有効数字の桁数までの2進数の組み合わせと、算出された前記所定の数の桁数を2で割った余りの数と、に応じて決定された定数を取得するステップと、
前記2進数表記された前記所定の数の桁数に応じて決定される、ビットシフト量を取得するステップと、
前記定数を、取得した前記ビットシフト量のビットシフトを実行するステップと、
前記ビットシフトを実行した前記定数を、前記所定の数の平方根として出力するステップ
とを備えることを特徴とする平方根演算方法。In a square root calculation method of approximating and calculating a predetermined number of square roots,
When the predetermined number is an integer,
Converting the predetermined number into binary notation;
Calculating the number of digits of the predetermined number expressed in a binary number;
A combination of a binary number from the second most significant bit of the predetermined number represented by the binary number to a predetermined number of significant digits, and a remainder obtained by dividing the calculated predetermined number of digits by 2 Obtaining a constant determined according to the number and
Obtaining a bit shift amount, which is determined according to the number of digits of the predetermined number represented by the binary number;
Performing the bit shift of the obtained bit shift amount with the constant,
Outputting the constant having undergone the bit shift as the square root of the predetermined number.
前記所定の数を2進数表記に変換するステップにおいて、前記所定の数が整数になるように、前記所定の数を乗数で乗して、乗した前記所定の数を2進数表記に変換し、
前記所定の数の平方根として出力するステップにおいて、前記ビットシフトを実行した前記定数を、前記乗数の平方根で除して、前記所定の数の平方根として出力する
ことを特徴とする請求項2に記載の平方根演算方法。When the predetermined number is a decimal,
In the step of converting the predetermined number into binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number is an integer, and the multiplied predetermined number is converted into binary notation,
The method according to claim 2, wherein, in the step of outputting as the square root of the predetermined number, the constant obtained by performing the bit shift is divided by the square root of the multiplier to output the constant as the square root of the predetermined number. Square root calculation method.
前記所定の数が整数の場合、
前記所定の数を2進数表記に変換するステップと、
2進数表記された前記所定の数の桁数を算出するステップと、
前記2進数表記された前記所定の数の上位2番目のビットから、所定の有効数字の桁数までの2進数の組み合わせと、前記累乗根の累乗根数と、算出された前記所定の数の桁数を前記累乗根の累乗根数で割った余りの数と、に応じて決定された定数を取得するステップと、
前記2進数表記された前記所定の数の桁数と前記累乗根数に応じて決定される、ビットシフト量を取得するステップと、
前記定数を、取得した前記ビットシフト量のビットシフトを実行するステップと、
前記ビットシフトを実行した前記定数を、前記所定の数の累乗根として出力するステップ
とを備えることを特徴とする累乗根演算方法。In a power root calculation method of calculating a predetermined number of power roots by approximation,
When the predetermined number is an integer,
Converting the predetermined number into binary notation;
Calculating the number of digits of the predetermined number expressed in a binary number;
A combination of binary numbers from the second most significant bit of the predetermined number represented by the binary number to a predetermined number of significant digits, a power root number of the power root, and the calculated predetermined number Obtaining a constant determined according to the number of digits and the remainder of dividing the number of powers by the number of powers of the power root,
A step of acquiring a bit shift amount, which is determined according to the number of digits of the predetermined number represented in the binary number and the number of power roots;
Performing the bit shift of the obtained bit shift amount with the constant,
Outputting the constant having been subjected to the bit shift as the predetermined number of power roots.
前記所定の数を2進数表記に変換するステップにおいて、前記所定の数が整数になるように、前記所定の数を乗数で乗して、乗した前記所定の数を2進数表記に変換し、
前記所定の数の累乗根として出力するステップにおいて、前記ビットシフトを実行した前記定数を、前記乗数の累乗根で除して、前記所定の数の累乗根として出力する
ことを特徴とする請求項4に記載の累乗根演算方法。When the predetermined number is a decimal,
In the step of converting the predetermined number into binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number is an integer, and the multiplied predetermined number is converted into binary notation,
The method according to claim 1, wherein, in the step of outputting as the root of the predetermined number, the constant having been subjected to the bit shift is divided by the root of the multiplier to output as the root of the predetermined number. 4. The method for calculating a power root according to 4.
前記所定の数が整数の場合、
前記所定の数を2進数表記に変換するステップと、
2進数表記された前記所定の数の桁数を算出するステップと、
前記2進数表記された前記所定の数の上位2番目のビットから、所定の有効数字の桁数までの、2進数の組み合わせと、累乗の累乗数に応じて決定された定数を取得するステップと、
前記2進数表記された前記所定の数の桁数と前記累乗数と、に応じて決定される、ビットシフト量を取得するステップと、
前記定数を、取得した前記ビットシフト量のビットシフトを実行するステップと、
前記ビットシフトを実行した前記定数を、前記所定の数の累乗として出力するステップ
とを備えることを特徴とする累乗演算方法。In a power calculation method of calculating a power of a predetermined number by approximation,
When the predetermined number is an integer,
Converting the predetermined number into binary notation;
Calculating the number of digits of the predetermined number expressed in a binary number;
Obtaining a constant determined according to a combination of binary numbers and a power of a power from the second most significant bit of the predetermined number represented by the binary number to a predetermined number of significant digits; ,
Obtaining a bit shift amount, which is determined according to the number of digits of the predetermined number represented by the binary number and the power,
Performing the bit shift of the obtained bit shift amount with the constant,
Outputting the constant after the bit shift as a power of the predetermined number.
前記所定の数を2進数表記に変換するステップにおいて、前記所定の数が整数になるように、前記所定の数を乗数で乗して、乗した前記所定の数を2進数表記に変換し、
前記所定の数の累乗として出力するステップにおいて、前記ビットシフトを実行した前記定数を、前記乗数の累乗で除して、前記所定の数の累乗として出力する
ことを特徴とする請求項6に記載の累乗演算方法。When the predetermined number is a decimal,
In the step of converting the predetermined number into binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number is an integer, and the multiplied predetermined number is converted into binary notation,
7. The method according to claim 6, wherein, in the step of outputting as a power of the predetermined number, the constant that has been subjected to the bit shift is divided by a power of the multiplier to output as a power of the predetermined number. Power operation method of.
前記所定の数が整数の場合、
前記所定の数を2進数表記に変換するステップと、
2進数表記された前記所定の数の桁数を算出するステップと、
前記2進数表記された前記所定の数の上位2番目のビットから、所定の有効数字の桁数までの2進数の組み合わせと、前記gと、前記hと、算出された前記所定の数の桁数を前記hで割った余りの数と、に応じて決定された定数を取得するステップと、
前記2進数表記された前記所定の数の桁数と前記累乗数に応じて決定される、ビットシフト量を取得するステップと、
前記定数を、取得した前記ビットシフト量のビットシフトを実行するステップと、
前記ビットシフトを実行した前記定数を、前記所定の数のg/h乗として出力するステップ
とを備えることを特徴とするg/h乗演算方法。In a g / h-th power calculation method in which a predetermined number of g / h powers (g and h are integers) are approximated and calculated,
When the predetermined number is an integer,
Converting the predetermined number into binary notation;
Calculating the number of digits of the predetermined number expressed in a binary number;
A combination of a binary number from the second most significant bit of the predetermined number represented by the binary number to a predetermined number of significant digits, the g, the h, and the calculated number of the predetermined number Obtaining a constant determined according to the number of remainders obtained by dividing the number by the h;
Obtaining a bit shift amount, which is determined according to the number of digits of the predetermined number represented by the binary number and the power,
Performing the bit shift of the obtained bit shift amount with the constant,
Outputting the constant having undergone the bit shift as the predetermined number of g / h powers.
前記所定の数を2進数表記に変換するステップにおいて、前記所定の数が整数になるように、前記所定の数を乗数で乗して、乗した前記所定の数を2進数表記に変換し、
前記所定の数のg/h乗として出力するステップにおいて、前記ビットシフトを実行した前記定数を、前記乗数のg/h乗で除して、前記所定の数のg/h乗として出力する
ことを特徴とする請求項8に記載のg/h乗演算方法。When the predetermined number is a decimal,
In the step of converting the predetermined number into binary notation, the predetermined number is multiplied by a multiplier so that the predetermined number is an integer, and the multiplied predetermined number is converted into binary notation,
In the step of outputting the predetermined number as the g / h power, the constant after the bit shift is divided by the multiplier to the g / h power to output the predetermined number as the g / h power. 9. The g / h power calculation method according to claim 8, wherein
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2002342406A JP2004178188A (en) | 2002-11-26 | 2002-11-26 | Calculation method, square root calculation method, power root calculation method, power calculation method and g/h-power calculation method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2002342406A JP2004178188A (en) | 2002-11-26 | 2002-11-26 | Calculation method, square root calculation method, power root calculation method, power calculation method and g/h-power calculation method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JP2004178188A true JP2004178188A (en) | 2004-06-24 |
Family
ID=32704487
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2002342406A Withdrawn JP2004178188A (en) | 2002-11-26 | 2002-11-26 | Calculation method, square root calculation method, power root calculation method, power calculation method and g/h-power calculation method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP2004178188A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2010058521A1 (en) * | 2008-11-19 | 2010-05-27 | 日本電気株式会社 | Square root calculation device and method and square root calculation program |
-
2002
- 2002-11-26 JP JP2002342406A patent/JP2004178188A/en not_active Withdrawn
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2010058521A1 (en) * | 2008-11-19 | 2010-05-27 | 日本電気株式会社 | Square root calculation device and method and square root calculation program |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Takagi | Powering by a table look-up and a multiplication with operand modification | |
| US10768898B2 (en) | Efficient modulo calculation | |
| JP3551113B2 (en) | Divider | |
| US8868633B2 (en) | Method and circuitry for square root determination | |
| KR100756137B1 (en) | Division and square root arithmetic unit | |
| Wang et al. | $(M, p, k) $-Friendly Points: A Table-Based Method to Evaluate Trigonometric Function | |
| JP2004178188A (en) | Calculation method, square root calculation method, power root calculation method, power calculation method and g/h-power calculation method | |
| JP3660075B2 (en) | Dividing device | |
| JP2000148447A (en) | Multiplier and arithmetic method therefor | |
| JPWO2011036746A1 (en) | Arithmetic unit | |
| CN104281433A (en) | Model calculation unit and control unit for calculating a data-based function model having data in various number formats | |
| JP2005228169A (en) | Random number generating device | |
| US6549924B1 (en) | Function generating interpolation method and apparatus | |
| CN102253924B (en) | Method for realizing root extraction arithmetic on hardware and root extraction arithmetic device | |
| Ugurdag et al. | Efficient combinational circuits for division by small integer constants | |
| JP2777265B2 (en) | High radix square root arithmetic unit | |
| JP2003084667A (en) | Method and device for performing a plurality of power residue calculation to same base, and program | |
| JPH0749769A (en) | Power calculation device | |
| KR100761132B1 (en) | Method for calculating SH-1 | |
| Patnayak et al. | Design Carry Select Adder With D-Latch | |
| JP2000010763A (en) | Division circuit | |
| JP2008021189A (en) | Division device and division method | |
| JP4954019B2 (en) | Arithmetic unit | |
| JPH01300338A (en) | Floating point multiplier | |
| JP2003303096A (en) | Division circuit |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A300 | Withdrawal of application because of no request for examination |
Free format text: JAPANESE INTERMEDIATE CODE: A300 Effective date: 20060207 |