JPS5858697B2 - power calculation method - Google Patents

power calculation method

Info

Publication number
JPS5858697B2
JPS5858697B2 JP8474876A JP8474876A JPS5858697B2 JP S5858697 B2 JPS5858697 B2 JP S5858697B2 JP 8474876 A JP8474876 A JP 8474876A JP 8474876 A JP8474876 A JP 8474876A JP S5858697 B2 JPS5858697 B2 JP S5858697B2
Authority
JP
Japan
Prior art keywords
register
power
exponent
calculation
bit
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.)
Expired
Application number
JP8474876A
Other languages
Japanese (ja)
Other versions
JPS5310237A (en
Inventor
伸一 田中
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.)
Sharp Corp
Original Assignee
Sharp Corp
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 Sharp Corp filed Critical Sharp Corp
Priority to JP8474876A priority Critical patent/JPS5858697B2/en
Publication of JPS5310237A publication Critical patent/JPS5310237A/en
Publication of JPS5858697B2 publication Critical patent/JPS5858697B2/en
Expired legal-status Critical Current

Links

Description

【発明の詳細な説明】 本発明は電子式卓上計算機(以下電卓という)等の簡易
な計算装置(こ極めて好適なべぎ計算方式電卓等におい
てはべき計算機能を有することがその使用上極めて有利
であって、四則演算しかできないような低価格の小型電
卓においてもべき計算機能が必ずといっていいほど付加
されている。
DETAILED DESCRIPTION OF THE INVENTION The present invention is applicable to simple calculation devices such as electronic desktop calculators (hereinafter referred to as calculators) (such as calculators using the exponent calculation method, which are extremely suitable). Therefore, even low-priced small calculators that can only perform four arithmetic operations almost always have a power calculation function added to them.

このような電卓(4その乗算機能を出来る限り有効に使
ってべき計算を行うため、A[El”lのキー操作でA
2を計算し、以刀困日なるキー操作毎tζ×Aなる乗算
を実行しべき乗A3.A4・・・・・・を得る方式ある
いはA[EElのキー操作でA2を計算し、以下日のキ
ー操作毎に×Aなる乗算を実行しべぎ乗A3゜A4・・
・・・・を得る方式が採用されている。
A calculator like this (4) In order to use its multiplication function as effectively as possible to perform exponentiation calculations, use the A [El"l key operation to
2, and then perform the multiplication tζ×A every time the key presses continue, and obtain the exponentiation A3. A method to obtain A4... or calculate A2 by pressing the A[EEI key, and then execute the multiplication xA for each key press on the following days to the power A3゜A4...
A method is adopted to obtain...

上述の方式はべき計算のための特別のプログラムを必要
としないが、求めるゞべき乗“が大きくなると、A11
Q→区日→区日・・・・・・の如くキー操作が煩雑にな
る上、操作者が凶日のキー操作回数を記憶しておかなけ
ればならない不都合があった。
The above method does not require a special program for power calculation, but when the desired power becomes large, A11
In addition, the key operations are complicated, such as Q→ku day→ku day, etc., and the operator has to memorize the number of key operations on bad days.

このような不都合をなくすため、A[mB[Eのキー操
作0(n:べき指示キー)で、自動的に(B−1)回の
乗算(×A)を繰り返えす方式があるが、乗算回数が極
めて多くなり演算時間が非常に長くなる欠点がある。
In order to eliminate this inconvenience, there is a method that automatically repeats the multiplication (×A) (B-1) times by pressing the key 0 (n: power instruction key) for A[mB[E. This method has the disadvantage that the number of multiplications is extremely large and the calculation time is extremely long.

これに対して、高価格の電卓は同様にAE]3日のキー
操作(Xn:べき指示キー)でAのB乗を計算するが、
この電卓ではべぎ乗をまず対数に変換し、その対数を計
算する方式が採用されている。
On the other hand, high-priced calculators similarly calculate A to the B power with the AE]3 key operation (Xn: power indication key).
This calculator uses a method that first converts the power to a logarithm, and then calculates the logarithm.

このような方式(」三角関数や対数等を求める機能を持
った高級電卓(こ(1向いているが、上述した低価格電
卓に採用しようとすれは、べき計算のためだけに対数計
算用の複雑なプログラム及び専用回路を設けなければな
らず価格が高くなり、かえって不向きである。
This method is suitable for high-end calculators with functions for calculating trigonometric functions, logarithms, etc., but if you are trying to use it in the low-priced calculator mentioned above, it is better to use a method for calculating logarithms only for exponentiation calculations. It requires a complicated program and a dedicated circuit, which increases the price, making it rather unsuitable.

上述のように低価格電卓の如き演算機能の単純な計算機
においては、通常細分化された命令語をもたず加減乗除
等の各演算を予め定められた順序に従って遂行していく
関係上、べき計算用として新たなルーチンを構成するこ
とは制御装置が複雑化し経済的でない。
As mentioned above, calculators with simple arithmetic functions such as low-cost calculators usually do not have subdivided command words and perform operations such as addition, subtraction, multiplication, and division in a predetermined order. Configuring a new routine for calculations complicates the control device and is not economical.

本発明は上述の点に鑑みなされたものでこの種計算機に
おいて特別のルーチンを組むことなく乗算ルーチンを有
効に利用し且つ若干の制御を付加するだけで極く短時間
でべき計算が行えるようにしたものである。
The present invention has been made in view of the above points, and it is possible to perform exponentiation calculations in a very short time by effectively utilizing the multiplication routine and adding some control in this type of computer without building a special routine. This is what I did.

以下、上記目的を達成するための好適な実施例(電卓)
を図面に従って説明する。
Below is a preferred embodiment (calculator) for achieving the above purpose.
will be explained according to the drawings.

本発明のべき計算方式は次のような全く新規な計算式に
基くものであるから、まずこの計算式を説明する。
Since the power calculation method of the present invention is based on the following completely new calculation formula, this calculation formula will be explained first.

AのB乗は 指数B(Bは整数)を B=2(p’)−ap+2(p−2)−a(p−1)−
1−、、、・、、2・a2+a1
・・・・・・・・・■但し、p:1,2.・・・・・
・、ap・・・・・・al:1orOの如く純2進数で
表わすと AB二A2(p−1)°apxA2(p−2)°a(p
→)x −・・・・・×A2°a2XAal
・・・・・・・・・◎と表わされる。
A to the B power is the exponent B (B is an integer) B = 2 (p') - ap + 2 (p - 2) - a (p - 1) -
1-, , , , 2・a2+a1
・・・・・・・・・■However, p: 1, 2.・・・・・・
・, ap...al: When expressed in pure binary numbers like 1orO, AB2A2(p-1)°apxA2(p-2)°a(p
→) x −・・・×A2°a2XAal
・・・・・・・・・It is expressed as ◎.

◎式ノ各項ヲAa1−AI、A2°a2=A2ノ如<置
くこ0式は次のように表わされる。
◎Place each term in the formula as follows: Aa1-AI, A2°a2=A2.0 The formula is expressed as follows.

AB=ApXMp−1)X・・・・・・A2XA1・・
・・・・・・・O 上述のAt〜Apは上記a1〜apが10“か11“で
あるから、 ai=oの場合 Al=A2−・・・・・・Ap=1 ・・・・
・・・・・@ai=1の場合 At二A”(” )=A=AI A2−A2(2−1)−げ−(At)2 A3:A2(3−1):((A)2)2:(A2)2A
4=A2(” )=(((A)2)2)”Ap−A2
(p−i )−(・・・・・((A)2)2・・・・・
・)2(A(p−1))2 ■ (A3)2 の何れかになる。
AB=ApXMp-1)X...A2XA1...
......O In the above At to Ap, the above a1 to ap are 10" or 11", so if ai=o, Al=A2-...Ap=1...
...@ai=1 At2A"(")=A=AI A2-A2(2-1)-ge-(At)2 A3:A2(3-1):((A) 2) 2: (A2) 2A
4=A2(” )=(((A)2)2)”Ap-A2
(p-i)-(...((A)2)2...
・)2(A(p-1))2 ■ (A3)2.

従って0式によればAのB乗はai=1であるAi項(
上記のに示す)のみ順次乗算したものであることがわか
る。
Therefore, according to Equation 0, A to the B power is the Ai term (
It can be seen that only (shown in above) are sequentially multiplied.

例えばal、a2.apがゝ1“で他のaiが全て10
“である場合、A B=Ap XA 2 ×AIとなる
For example, al, a2. AP is “1” and all other AIs are 10
“, then AB=Ap XA 2 ×AI.

しかも上記■における各項At〜Apは底Aの21乗(
i:otlt2t・・・・・・)に等しく、A2〜Ap
はそれぞれ前項A1〜A(p−1)の2乗になっている
Moreover, each term At to Ap in the above ■ is the base A to the 21st power (
i:otlt2t...), A2~Ap
are respectively the squares of the previous terms A1 to A(p-1).

逆に考えれば、底Aを元にして2乗を繰り返してai=
1の場合のA2〜Apを求め、このうちai=1である
Aiのみ選択して更に乗算すればAのB乗が得られるは
ずである。
If you think about it the other way around, you can repeat squaring based on the base A and get ai=
If A2 to Ap in the case of 1 are found, only Ai where ai=1 is selected and further multiplied, A to the B power should be obtained.

本発明のべき計算方式は上述の思想に基づいてなされた
ものであって、その具体化された構成を以下に説明する
The power calculation method of the present invention is based on the above-mentioned idea, and its concrete configuration will be described below.

第1図は電卓に実施された場合の要部ブロック図でアル
Figure 1 is a block diagram of the main parts when implemented in a calculator.

第1図において主要な構成要素はABを得るためのN桁
容量のXレジスタと、Aの21乗を得るためのN桁容量
のYレジスタと、指数Bを純2進コードで記憶するため
のNビットのWレジスタとである。
In Fig. 1, the main components are an and an N-bit W register.

上記Wレジスタには上記■式のビットaiが′1“かゝ
0“かを判定するため最下位ビットW1に接続されたア
ントゲ−14N1と、指数Bの最上位ビットapを判断
するための、W2〜WNの出力を人力とするノアゲ゛−
トNORとが設けられている。
The above W register has an ant game 14N1 connected to the least significant bit W1 to determine whether bit ai of the above equation ``1'' or 0'', and an ant game 14N1 connected to the least significant bit W1 to determine the most significant bit ap of the exponent B. A no-game that uses human power to output W2 to WN.
and NOR are provided.

ZはN桁容量の補助用レジスタで主にAの2i乗を求め
る場合に使用される。
Z is an auxiliary register with an N-digit capacity, and is mainly used when calculating A to the 2i power.

FAIは全加減算器でレジスクX、Y、Z相互間の乗算
を実行する(なお以下FAIと略す)。
FAI is a full adder/subtracter that executes multiplication between registers X, Y, and Z (hereinafter abbreviated as FAI).

AN2〜ANnは本発明を達成する際、使用されるアン
ドゲートで、その動作は以下の説明から明らかになろう
AN2 to ANn are AND gates used in achieving the present invention, and their operation will become clear from the following description.

ROMは演算制御部で上記構成要素を制御する制御信号
■、■・・・・・・を発生する。
The ROM is an arithmetic control unit that generates control signals (2), (2), etc. for controlling the above-mentioned components.

DCはレジスタXに当初、2進化lO進コードで記憶さ
れた指数Bを純2進コードに変換してWレジスタに導入
するためのコード変換器である。
DC is a code converter for converting the exponent B, which was initially stored in the register X as a binary coded 1O base code, into a pure binary code and introducing it into the W register.

上記X、Y、Zレジスタは記憶内容を循環保持する循環
保持機能、(X−+X、Y−+Y、Z−+Zで表わす)
、記憶内容を他のレジスタにそっくり移してしまう転送
機能(x−+y、Y−)Z等で表わす)及び記憶内容を
保持しながら他のレジスタに同じ内容を記憶させる転写
機能(X−)X、x−+y 、Y→y、y−+z、等で
表わす)等を有しているが自己保持用の循環ループは図
示していない。
The above X, Y, and Z registers have a circular holding function that circularly holds the memory contents (represented by X-+X, Y-+Y, Z-+Z).
, a transfer function (represented by x-+y, Y-)Z, etc.) that transfers the entire memory contents to another register, and a transfer function (X-)X that stores the same contents in other registers while retaining the memory contents. , x-+y, Y→y, y-+z, etc.), but a self-maintaining circulation loop is not shown.

次に上記構成によって、AのB乗(Bは正の整数)を得
る動作を第2図のフローチャートに従って説明する。
Next, the operation of obtaining A to the power of B (B is a positive integer) using the above configuration will be explained with reference to the flowchart of FIG.

キーボード上の数値キーを操作することによって数値A
がまずXレジスタに記憶される。
Enter the number A by operating the number keys on the keyboard.
is first stored in the X register.

続いて巨Qロキーの操作によってべき計算指示が上ip
に記憶される。
Next, by operating the giant Q lokey, the power calculation instruction is given to the upper ip.
is memorized.

ここで数値キーにて指数Bを指示すると、Xレジスタの
内容AはゲートAN2を介してYレジスタに転送されX
レジスタには指数Bが記憶される。
Here, when you specify exponent B using the numeric keys, the contents A of the X register are transferred to the Y register via gate AN2.
An exponent B is stored in the register.

次に日キーを操作するとべき計算が開始されるが、その
第1ステツプf1においてROMより開側御信号■を発
生しゲートAN3を介して指数Bをコード変換器DCに
導入し、純2進数に変換した後Wレジスタに記憶させる
Next, when the date key is operated, the calculation starts, and in the first step f1, the open side control signal ■ is generated from the ROM, and the exponent B is introduced into the code converter DC through the gate AN3, and the pure binary number is After converting to , it is stored in the W register.

次のステップf2においては上記Xレジスタに10“を
記憶させる。
In the next step f2, 10'' is stored in the X register.

なおfi、f)ステップの動作は同一ステップでも行う
ことができる。
Note that the operations in steps fi and f) can be performed in the same step.

上記f2ステップ終了状態ではレジスタYに底Aが2進
化■0進コードで配置され、レジスタWに上記0式のa
l、A2.曲・・apが最下位ビットW■から順に記憶
されている。
In the state where the f2 step is completed, the base A is placed in the register Y as a binary code ■0 base code, and the a of the above 0 formula is placed in the register W.
l, A2. Songs...ap are stored in order from the least significant bit W■.

ここで上記0式におけるA1を求めるため、制御信号■
によってゲートAN1をオンし、Wlビットの内容(即
ちal)を判定する(f3ステップ〕。
Here, in order to find A1 in the above equation 0, the control signal ■
turns on the gate AN1 and determines the contents of the Wl bit (ie, al) (step f3).

W l == a 、 = 1であればA1=Aである
から信号■によってゲートAN4 、AN5をオンして
レジスタYの内容AをレジスタXへ転送(y−+x)し
、レジスタXにAの1乗を得る。
If W l == a, = 1, then A1=A, so the signal ■ turns on gates AN4 and AN5, transfers the contents A of register Y to register X (y-+x), and transfers the contents of A to register X. Get the first power.

この場合、Yの内容Aは保持(Y−+Y )されている
Cf5ステツプ〕。
In this case, the content A of Y is held (Y-+Y) in step Cf5].

W1=a1=:0であればA1−1であるから信号■に
よってゲートAN6 、AN7 、AN5をオンし、X
−+−t→Xを行いレジスタXにAの0乗即ちゝ1“を
得る(f4ステップ」。
If W1=a1=:0, it is A1-1, so gates AN6, AN7, and AN5 are turned on by signal ①, and X
-+-t→X to obtain A to the 0th power, ie, "1", in register X (f4 step).

このように、本発明によれば、第1項A1の値のみ乗算
なしでXレジスタに記憶させている。
As described above, according to the present invention, only the value of the first term A1 is stored in the X register without being multiplied.

次に0式のA2の値を求めるためにf6ステツプに移り
クロックφiによってWレジスタの内容を1ビツト右シ
フトし、ビット値a2をWlに位置させる。
Next, in order to obtain the value of A2 of the 0 formula, the process moves to step f6, and the contents of the W register are shifted to the right by 1 bit using the clock φi, and the bit value a2 is placed in Wl.

そしてa 2 = 1の場合に相当するA2をレジスタ
Yに求めるために制御信号■によってゲートAN8をオ
ンして転写(Y−)Z 、 y−+y )を行い、制御
信号をゆで、レジスクY、Z間の乗算をFAIで実行し
、その結果をYレジスタに得る(Y−Z−)Y)。
Then, in order to obtain A2 corresponding to the case of a 2 = 1 in the register Y, the gate AN8 is turned on by the control signal ■ and transfer (Y-)Z, y-+y) is performed, and the control signal is boiled and the register Y, Perform the multiplication between Z using FAI and obtain the result in the Y register (Y-Z-)Y).

これでYレジスタにはA2が記憶される。A2 is now stored in the Y register.

(f7ステツプ〕。(f7 step).

この状態でA2が11“か否かを制御信号■を使って判
定し、a2=1であれば制御信号■でレジスタX、Y間
の乗算を実行し、その結果Al−A2をXレジスタに得
る(X−?X)(f9ステップ〕。
In this state, use the control signal ■ to determine whether A2 is 11'', and if a2 = 1, use the control signal ■ to execute multiplication between registers X and Y, and as a result, put Al-A2 into the X register. Obtain (X-?X) (f9 step).

この場合、Yレジスタの内容A2は保存されている。In this case, the contents A2 of the Y register are preserved.

A2−0であればA2二1であるから乗算は実行せずX
レジスタの内容A1はそのままである。
If A2-0, then A221, so no multiplication is performed and X
The contents A1 of the register remain unchanged.

上記f6〜f9ステップまでの動作によって、A2がゝ
1“である場合のA2を求め、A2が11“であるか否
かを判定し、その判定結果に応じて第2項A2までのべ
き乗Al、A2あるいはA、をXレジスタに得たことに
なる。
By the operations from steps f6 to f9 described above, A2 is obtained when A2 is "1", it is determined whether A2 is 11", and the power Al up to the second term A2 is determined according to the determination result. , A2 or A in the X register.

あとはAのB乗がA2項までか更にあるかを判定すれば
よい。
All that is left to do is to determine whether A raised to the B power is up to the A2 term or further.

これはfloステップにおいて行なわれる。This is done in the flo step.

即ちW2〜WNビット出力を入力とするノアゲートNO
Rがゝ1“の場合W2〜WNは何れもゝO“であるから
指数Bのビン133以上の値はなくここで演算を終了す
る。
That is, the NOR gate NO which inputs the W2 to WN bit outputs.
When R is "1", W2 to WN are all "O", so there is no value greater than bin 133 of index B, and the calculation ends here.

しかしN0R=0の場合W2〜WNの何れかに′Xl“
があるから引□続き演算を実行するため再度Wレジスタ
の内容を1ビツト右シフトする。
However, when N0R=0, any one of W2 to WN has 'Xl''
Since there is □, the contents of the W register are shifted to the right by 1 bit again in order to continue the operation.

f6ステツプに戻る。以後、最上位ビットapがWレジ
スタの最下位ビットWlに来るまで上述の動作〔f6〜
f10〕を繰り返えせば、ビット値a1が11“の項の
み順次レジスタXの内容に乗算され、AのB乗が得られ
る。
Return to f6 step. Thereafter, the above operation [f6~
f10], only the terms whose bit value a1 is 11" are sequentially multiplied by the contents of the register X, and A raised to the B power is obtained.

上記計算方式による乗算回数は次のようになる。The number of multiplications using the above calculation method is as follows.

乗算が行なわれるのはf6〜flOステップの間であっ
てこの1回の動作においては、Aの21乗を得る乗算(
y−z−+y)と、ai==1の時の乗算(X−Y−)
X)の2回だけである。
Multiplication is performed between steps f6 and flO, and in this one operation, multiplication to obtain A to the 21st power (
y-z-+y) and multiplication (X-Y-) when ai==1
X) only twice.

従って、a1〜apが全て11“の場合でも、AのB乗
は2(P−0回の乗算で得ることができる。
Therefore, even if a1 to ap are all 11'', A to the B power can be obtained by multiplying 2 (P-0 times).

この回数は単純に(B−1)回乗算する場合に比して極
めて少くなる。
This number of times is extremely small compared to the case of simply multiplying (B-1) times.

即ちN桁の10進数BがPビットの2進数で表わせたと
すると10−2となる。
That is, if an N-digit decimal number B is expressed as a P-bit binary number, it becomes 10-2.

この対数をとればNloglO=Plog 2となり対
数表に従えば N中0.3Pとなる。
If we take this logarithm, NloglO=Plog 2, and according to the logarithm table, it becomes 0.3P in N.

■0 従って2(P−1)=2(了N−1)となり、(B−1
)=lON−tと大小関係を比較すると、1oN−1≦
2(WN−1) 〉 3 となる。
■0 Therefore, 2 (P-1) = 2 (RyoN-1), and (B-1
)=lON-t and the magnitude relationship, 1oN-1≦
2(WN-1)>3.

Nは1以上の整数であるから、Nが大きくなる程即ち指
数Bが犬ぎくなる程、本発明方式に従えば乗算回数を節
約できることがわかる。
Since N is an integer greater than or equal to 1, it can be seen that the larger N is, that is, the more extreme the exponent B is, the more the number of multiplications can be saved according to the method of the present invention.

叙上のように本発明は上述した計算式を最も効率よ〈実
施するために、 OAのB乗を得るレジスタとAの21乗を得るレジスタ
を別個に設けること、 ○ 0式におけるビットalを下位ビットから順次判定
すること、 ○ まずA1の値を求め、次にa 2 = 1の場合の
A2の値を求め、alが11”の時は更に乗算Al、A
2を行い、次にa3−1の場合のA3の値をa2−■の
場合のA2の値を利用して求め、a3が11/′ならば
上記A1.A3にA3を乗算するといった方式を繰り返
えすこと、 等の工夫を施こしている。
As mentioned above, in order to implement the above calculation formula most efficiently, the present invention provides two separate registers for obtaining OA to the B power and a register for obtaining A to the 21st power. Make decisions sequentially starting from the lower bits. ○ First, find the value of A1, then find the value of A2 when a 2 = 1, and if al is 11", then multiply Al, A
2, then find the value of A3 in the case of a3-1 using the value of A2 in the case of a2-■, and if a3 is 11/', then calculate the value of A3 in the case of a3-1 using the value of A2 in the case of a2-■. We have taken measures such as repeating the method of multiplying A3 by A3.

上記実施例においてはf8ステップ、f9ステップの後
は必ずf10ステップを通って16ステツプlこ反って
いるが、第2図破線で示すようにf9ステップ後は直接
f6ステツプへ戻ってもよい。
In the above embodiment, after the f8 step and the f9 step, the process always passes through the f10 step and is warped by 16 steps, but as shown by the broken line in FIG. 2, the process may directly return to the f6 step after the f9 step.

このようにすれば、f10ステップを通る回数が少くな
る。
In this way, the number of times the f10 step is passed is reduced.

なお、このフローを実現するにはNORゲートの入力を
WN−Wlとすればよい。
Note that to realize this flow, the input of the NOR gate may be set to WN-Wl.

以上、説明したように指数Bが正の整数の場合非常に簡
単にABを求めることができる。
As explained above, when the exponent B is a positive integer, AB can be found very easily.

しかし、指数が負の整数(例えば−B)の場合上記方式
ではA−Bを求めることができない。
However, if the exponent is a negative integer (eg -B), AB cannot be determined using the above method.

もちろんA−B=l/ABであるからABを上記方式で
求めた後IEIAB日なる操作でA−Bを求めることは
可能であるが、その場合でもA−Bを求めるキー操作よ
、A3BG→求まったABを別に記憶→1円AB日・・
・・・・・−>A−13となり大変複雑になる。
Of course, since A-B=l/AB, it is possible to find A-B using the above method and then IEIAB, but even in that case, the key operation to find A-B is A3BG→ Memorize the obtained AB separately → 1 yen AB day...
...->A-13, which makes it very complicated.

現在の電卓は数式通りのキー操作によって答を得るよう
に工夫されており、上記の如き複雑なキー操作を必要と
するものは不都合である。
Current calculators are devised to obtain answers by key operations according to mathematical formulas, and calculators that require complex key operations as described above are inconvenient.

そこで本発明では上述の如き欠点を除去するためeEB
日なるキー操作でA−Bが求まるようにしている。
Therefore, in the present invention, in order to eliminate the above-mentioned drawbacks, the eEB
A-B can be found by pressing the keys every day.

以下、AIE”1EIB日なるキー操作でA、−Bを極
めて簡単に求める方式を説明する。
Hereinafter, a method for extremely easily obtaining A and -B by key operations such as AIE"1EIB will be explained.

この方式の基本的な考え方は次の通りである。The basic idea of this method is as follows.

よ−B−圭一(縞B BlA であるから、λを底と考えればA はA を求めるのと
全く同一の方式で求めることができるはずである。
Yo-B-Keiichi (Since the fringe B BlA , if we consider λ to be the base, A should be able to be found using exactly the same method as finding A .

第4図は上記の考え方を電卓に具体化した場合のフロー
チャートであって、f l −f :2ステツプ及びf
3ステップからf10ステップまでは第2図と全く同様
である。
FIG. 4 is a flowchart when the above idea is embodied in a calculator.
Steps from step 3 to step f10 are exactly the same as in FIG. 2.

第4図から明らかなよつにAとA の何れでも求められ
るフローチャートとA を求めるフローチャートが異な
る所はf2とf3ステップとの間にgl、g2.g3ス
テップが介在することである。
As is clear from FIG. 4, the difference between the flowchart for finding both A and A and the flowchart for finding A is that gl, g2. g3 step is involved.

この3ステツプの動作も第1図に示す構成で達成できる
が、その説明を容易にするため、上記3ステツプの動作
達成のためのブロック回路を第3図に示す。
This three-step operation can also be achieved with the configuration shown in FIG. 1, but for ease of explanation, a block circuit for achieving the three-step operation is shown in FIG.

同図において第1図と同一部分は同一符号を示す。In this figure, the same parts as in FIG. 1 are designated by the same reference numerals.

第3図においてXSは通常Xレジスタの数値情報の符号
をゝl“ %Q“で記憶する符号記憶器で日キーの操作
毎に状態を反転する。
In FIG. 3, XS is a code memory which normally stores the sign of numerical information in the X register as ``1%Q'', and its state is inverted every time the date key is operated.

XSはX5=tなら負をX5=Oなら正を表わす。XS represents a negative value if X5=t, and a positive value if X5=O.

本発明は上記XSをフローチャート選択を*1Jflす
る状態判定器として使用しているがその働きは以下の説
明から明らかになろう。
The present invention uses the above-mentioned XS as a status determiner for *1Jfl selection of flowcharts, and its function will become clear from the following explanation.

次にA−Bを求める動作を第1図、第3図、第4図を参
照して説明する。
Next, the operation for determining A-B will be explained with reference to FIGS. 1, 3, and 4.

キーボード上の各キーを[Bと操作した 時の状態はXSがゝl”になる以外、C−]”Bとキ操
作した時と同様である。
The state when each key on the keyboard is operated as [B] is the same as when the key is operated as C-]''B, except that XS becomes ``l''.

ここで日キーを操作すると、第4図のfl 、f2ステ
ップを実行するが、この動作は第2図のfl、f2ステ
ップと全く同様である。
If the date key is operated here, the fl and f2 steps in FIG. 4 are executed, but these operations are exactly the same as the fl and f2 steps in FIG.

ここで指数が正か負かを符号判定器XSの出力で判定す
る(g1ステップ)。
Here, whether the exponent is positive or negative is determined based on the output of the sign determiner XS (step g1).

出力が0“なら指数は正であるからf3ステップに移り
ABを求める既述の動作を行う。
If the output is 0'', the exponent is positive, so the process moves to step f3 and performs the operation described above to obtain AB.

これに対してXSの出力がゝ1 // (1ら指数は負
であるからAの逆数を求めるステップに移る。
On the other hand, the output of XS is 1 // (Since the exponent is negative from 1, we move on to the step of finding the reciprocal of A.

まず制御信号0によってゲートAN8をオンしYレジス
タの内容AをXレジスタに転送すると共(こゲートAN
6.AN7.AN5をオンし、FAIでX+lを実行し
、その結果をXに導入する(g2ステップ)。
First, the control signal 0 turns on the gate AN8 and transfers the contents A of the Y register to the X register (this gate AN8
6. AN7. Turn on AN5, execute X+l on FAI, and introduce the result to X (g2 step).

次に制御信号Qす、OでX/Zなる除算をFAIで実行
し、その結果をYレジスタに得る( X/Z→Y)。
Next, a division of X/Z is executed in FAI using the control signals Q and O, and the result is obtained in the Y register (X/Z→Y).

この除算は電卓に予め備わっている除算ルーチンを利用
すればよいから、特別にルーチンを組んだり追加したり
する必要がない。
This division can be performed by using a division routine that is already provided in the calculator, so there is no need to create or add a special routine.

又上記除算はいわゆるスリーレジスタ方式を利用してい
るので演算結果の有効桁数はN桁となる。
Furthermore, since the above division uses the so-called three-register method, the number of effective digits of the operation result is N digits.

即ち、制御信号■の発生期間において、(X−Z)を実
行しこの結果が10“が正なら、制御信号0りの発生期
間中にY+1−)Yを実行し、更に次の0発生期間中(
X−Z)を実行する如く制御信号@)、@を交互)こ発
生し、商をYレジスタに得るからレジスタYの桁数を商
とすることができる。
That is, during the period in which the control signal ■ is generated, execute (X-Z), and if the result is 10'' is positive, execute Y+1-)Y during the period in which the control signal 0 occurs, and then perform the next 0 generation period. During(
Since the control signals @) and @) are generated alternately to execute X-Z) and the quotient is obtained in the Y register, the number of digits in the register Y can be used as the quotient.

上記(X−Z )実行時には減算命令SubがFAIに
供給されFAlを減算器として動作させる。
When the above (X-Z) is executed, the subtraction instruction Sub is supplied to FAI, causing FAl to operate as a subtracter.

なお除算の制御は上述の他に被演算数、演算数の桁合せ
、大小判定、左右シフト等の制御を行なわなければなら
ないが、この点については周知なので詳細な説明は省略
する。
In addition to the above-mentioned division control, it is necessary to control the operands, digit alignment of the operands, magnitude determination, left/right shift, etc., but since this point is well known, a detailed explanation will be omitted.

又、2レジスタ方式の除算を行えば商の有効桁数は(N
−除数桁)となるが、上記(X−Z )及びY+1−)
Yなる動作を同一サイクルで実行できるので除算処理時
間を短縮することができる。
Also, if you perform division using the two-register method, the number of significant digits of the quotient will be (N
- divisor digit), but the above (X-Z) and Y+1-)
Since the operation Y can be executed in the same cycle, the division processing time can be shortened.

除算が終了した後、制御信号Q)によって、XZXレジ
スタ自己保持ループをしゃ断し、X=OZOとする(図
示せず)。
After the division is completed, the control signal Q) interrupts the XZX register self-holding loop to set X=OZO (not shown).

上記動作の終了によってg3ステップが終りf3ステッ
プlこ移る。
Upon completion of the above operation, the g3 step ends and the process moves to the f3 step l.

以後の動作は既述の通りである。The subsequent operations are as described above.

第5図はA−Bを求める場合、まずABを求め指数が負
の場合は1/A Bを実行する方式のフローチャートで
ある。
FIG. 5 is a flowchart of a method in which when calculating A-B, AB is first obtained and if the exponent is negative, 1/A B is executed.

この場合のキー操作はAIE□EIBEIで第4図の場
合と同様であるが、動作は指数が正の場合の方式とf1
0ステップ(第2図)まで全く同様である。
The key operation in this case is AIE□EIBEI, which is the same as the case in Figure 4, but the operation is the same as when the exponent is positive.
It is exactly the same up to step 0 (FIG. 2).

第2図ではflOステップで終了するが第5図の場合、
更にg4ステップに移りXSの内容を判定する。
In Fig. 2, it ends at the flO step, but in Fig. 5,
Further, the process moves to step g4 and the contents of XS are determined.

X5=Oならこれで演算は終了するがX5=1ならg5
ステップに移りXの内容ABをYに転送し且つZにゝl
“を記憶する。
If X5=O, the calculation ends, but if X5=1, g5
Move to step, transfer contents AB of X to Y, and transfer ゝl to Z.
“Remember.

そして、g6ステツプにおいてZ/Yなる除算を実行し
、その商をXレジスタに得て、処理を終了する。
Then, in step g6, division Z/Y is executed, the quotient is obtained in the X register, and the process is completed.

上記g4〜g6ステツプを達成する回路は図示しないが
第3図と大差はない。
Although the circuit for accomplishing the above steps g4 to g6 is not shown, there is no major difference from that in FIG.

叙上のようにA−Bを電卓において求める場合ABを求
める方式を利用すれば、予め組み込まれている除算ルー
チンを一度使用するだけで極めて簡単に答を得ることが
できる。
As mentioned above, when calculating AB using a calculator, by using the method for calculating AB, the answer can be obtained extremely easily by using the pre-installed division routine once.

即ち、XSを符号判定器として利用すること及びg1〜
g3あるいはg4〜g6のステップを設けることによっ
て、複雑なキー操作をしなければならないA−Bを極め
て簡単なキー操作で求めることが可能となり、電卓等で
は好都合となる。
That is, using XS as a sign determiner and g1~
By providing steps g3 or g4 to g6, A-B, which requires complicated key operations, can be obtained by extremely simple key operations, which is convenient for calculators and the like.

次に第4図のフローチャートを使用した場合の演算例(
’) −13=8192の状態推移図を第6図に示す(
但しf9→f6のルートは第2図の波線の方を使用する
)。
Next, an example of calculation when using the flowchart in Figure 4 (
') -13=8192 state transition diagram is shown in Figure 6 (
However, for the route from f9 to f6, use the wavy line in Figure 2).

上記の場合ゝ13“は4ビツトで表わされ、このうち最
下位ビット以外の11“のビットは12“こあるから、
乗算回数は 破線のフローチャートを使用した場合、 Y2→Yの乗算 ・・・・・・4回 X−Y→Xの乗算・・・・・・2回 言+6回となる
In the above case, ``13'' is represented by 4 bits, and there are 12'' bits in 11'' other than the least significant bit.
When the broken line flowchart is used, the number of multiplications is: Y2→Y multiplication: 4 times X-Y→X multiplication: 2 times Word+6 times.

破線のフローチャートを使用しない場合、’8192“
を求めた時点でN0R=1となるから、この時点で演算
が終了してしまう。
'8192“ if you do not use the dashed flowchart
Since N0R=1 at the time when is calculated, the calculation ends at this point.

従って、“′−Y0乗算 −°−3回 計、。Therefore, "'-Y0 multiplication -°-3 times,"

X−Y→Xの乗算・・・・・・2回 となる。Multiplication of X-Y→X...2 times becomes.

従来の方法では(13−1)=12回の乗算が必要であ
るから、本発明の方式が如何に効率的であるかがわかる
Since the conventional method requires (13-1)=12 multiplications, it can be seen how efficient the method of the present invention is.

以上のように本発明方式によればべき計算の場合の乗算
回数を減らすことができる。
As described above, according to the method of the present invention, the number of multiplications in power calculation can be reduced.

又、本発明によれば従来の低価格電卓の構成をほとんど
そのまま利用できる上、はとんど付加回路を必要として
いない。
Further, according to the present invention, the configuration of conventional low-cost calculators can be used almost as is, and additional circuits are hardly required.

即ち、第1図の構成)こおいて、ROM、X、YZ。Namely, in the configuration shown in FIG. 1), ROM, X, YZ.

FAI、各ゲート及びf2.f4.f5.f7゜f9ス
テップの動作等vマ通常の電卓に具えられているもので
、新たにコード変換器DC、WレジスタAN1、ゲート
NOR等が付加されたにすぎない。
FAI, each gate and f2. f4. f5. The operations of f7° to f9 steps, etc., are included in a normal calculator, but a code converter DC, a W register AN1, a gate NOR, etc. are simply added.

もつとも、W、ANl 、NOR等は演算機能の高い電
卓における構成要素を兼用することが可能である。
However, W, ANl, NOR, etc. can also be used as components in a calculator with high arithmetic functions.

又、低価格の電卓でも、指数Bを15以内と制限すれば
Wレジスタは4ビツトでよいから、べき計算時使用しな
い小数点レジスタy(例えばYレジスタの小数点位置を
記憶するレジスタ)を共用することができる。
Also, even in low-priced calculators, if the exponent B is limited to 15 or less, the W register only needs to be 4 bits, so the decimal point register y (for example, the register that stores the decimal point position of the Y register), which is not used during exponentiation calculations, can be shared. I can do it.

この小数点レジスタyにはその内容が′O“か否かを判
定するゲー トも付随しているので、これをNORとし
て使用することもできる。
This decimal point register y is also accompanied by a gate that determines whether its contents are 'O' or not, so it can also be used as a NOR.

又、数値は通常2進化10進コードで表わされているか
ら上記の場合にはコード変換器DCも不要になる。
Furthermore, since numerical values are usually expressed in binary coded decimal codes, the code converter DC is also unnecessary in the above case.

従って通常の電卓にほとんど回路を付加することなく、
指図の各ビットが11“か10“かに応じてX、Y、Z
の何れのレジスタ間の乗算及び除算を実行するかの制御
を付加するだけで、乗算ルーチン、除算ルーチンを有効
に使用したべぎ計算機能も付加することができる。
Therefore, without adding almost any circuit to a normal calculator,
X, Y, Z depending on whether each bit of the instruction is 11" or 10"
By simply adding control over which registers to perform multiplication and division, it is possible to add a multiplication function that effectively uses the multiplication and division routines.

又、上記実施例では2進化lO進コードをコード変換器
DCで純2進コードに変換していたが次のようにしてコ
ード変換してもよい。
Further, in the above embodiment, the binary code is converted into a pure binary code by the code converter DC, but the code may be converted as follows.

レジスタXの内容BからFAiを使って11“を引く毎
に(この減算は2進化10進コード計算である)。
Each time 11" is subtracted from the contents B of register X using FAi (this subtraction is a binary coded decimal code calculation).

レジスタWに11“を純2進法加算する。Add 11" to register W in pure binary.

この場合上記FAIを利用することができる。In this case, the above FAI can be used.

即ち、FAlは2つの全加減算器の間に6補正用4ビッ
トレジスタが挿入され2進化10進コード用の加減算器
となっており、個々の加減算器は純2進の加減算を行う
That is, in FAl, a 4-bit register for 6 correction is inserted between two full adders/subtracters to form an adder/subtracter for binary coded decimal code, and each adder/subtractor performs pure binary addition/subtraction.

従ってWレジスタに′l“加算を行う場合は6補正用レ
ジスタに入力する内容をそのまま加減算器FAIの出力
として取り出せばよい。
Therefore, when adding 'l' to the W register, the contents input to the 6th correction register can be taken out as they are as the output of the adder/subtractor FAI.

このようにコード変換にFAIを使用すれば、コード変
換器DCは不要になる。
If FAI is used for code conversion in this way, the code converter DC becomes unnecessary.

本発明は上述のように指数Bを純2進数に変換し、この
値をもとに数値Aの2のべき乗乗を得る制御手段を付加
すると共に指数Bの正、負を判定する手段を付加するだ
けで大部分を乗・除算ルーチンと共用しているので新た
なルーチンを設けることなく簡単安価な構成で、指数B
が正負何れであってもそのべき乗を計算する計算機能を
得ることができる。
The present invention converts the exponent B into a pure binary number as described above, adds a control means for obtaining the power of 2 of the numerical value A based on this value, and also adds means for determining whether the exponent B is positive or negative. Since most of the routines are shared with the multiplication/division routines, the exponent B can be easily and inexpensively configured without creating any new routines.
It is possible to obtain a calculation function that calculates the exponentiation regardless of whether it is positive or negative.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図は本発明の一実施例のブロック図、第2図はその
動作説明に供するフローチャート、第3図は本発明方式
による一実施例の要部ブロック図、第4図はその動作説
明に供するフローチャート、第5図は他の実施例の動作
説明に供するフローチャート、第6図は本発明方式によ
る演算例の説明図である。 符号、XS:符号判定器、x、y、z−レジスクψW:
純2進数レジスタ、FAl:全加減算器、DC:コード
変換器、NOR:ノアゲート、AN1ニアンドゲート、
ROM:演算側脚部。
FIG. 1 is a block diagram of an embodiment of the present invention, FIG. 2 is a flowchart for explaining its operation, FIG. 3 is a block diagram of main parts of an embodiment according to the method of the present invention, and FIG. 4 is for explaining its operation. FIG. 5 is a flowchart for explaining the operation of another embodiment, and FIG. 6 is an explanatory diagram of an example of calculation according to the method of the present invention. Sign, XS: sign determiner, x, y, z-regisc ψW:
Pure binary register, FAl: Full adder/subtractor, DC: Code converter, NOR: NOR gate, AN1 Niand gate,
ROM: Operation side leg.

Claims (1)

【特許請求の範囲】 1 数値AのB乗(但しBは整数)を計算するゝべき計
算“において、 上記指数Bを純2進コードで記憶する指数用レジスタと
、 該指数の符号を記憶する手段と、 上記数値Aを記憶する底円レジスタと、 上記指数用レジスタのビット内容が11”かXX□“か
を下位ビットから順次判定する手段と上記底円レジスタ
の内容を底とし11“と判定されたビットの重みに相当
するゞべき乗“を得る第1の演算手段と、この演算結果
を順次乗算してその乗算結果を得る第2の演算手段と、
上記符号記憶手段が負符号を記憶している場合上記底周
レジスクの内容Aを予めl/Aにする第3の演算手段と
から成り、上記第2の演算手段の演算結果がAのB乗と
なるように制御することを特徴とするべき計算方式。 2 数値AのB乗(但しBは整数)を計算する1べき計
算“において、 上記指数Bを純2進コードで記憶する指数用レジスタと
、該指数の符号を記憶する手段と、上記数値Aを記憶す
る底円レジスタと、 上記指数用レジスタのビット内容が11“か10“かを
下位ビットから順次判定する手段と上記底円レジスタの
内容を底とげ1“と判定されたビットの重みに相通する
1べき乗”を得る第■の演算手段と、この演算結果を順
次乗算してその乗算結果を得る第2の演算手段と、上記
符号記憶手段が負符号を記憶している場合、上記第2の
演算手段による乗算結果の逆数を得る第3の演算手段と
から収り、上記第2の演算手段の演算結果あるいは第3
の演算手段の演算結果がAのB乗となるように制御する
ことを特徴とするべき計算方式。
[Scope of Claims] 1. In "power calculation" that calculates the B power of a numerical value A (where B is an integer), an exponent register that stores the exponent B as a pure binary code, and stores the sign of the exponent. means for sequentially determining whether the bit content of the exponent register is 11" or XX□" from the lower bit; a first arithmetic means that obtains a power corresponding to the weight of the determined bit; a second arithmetic means that sequentially multiplies the arithmetic results to obtain the multiplication result;
and third arithmetic means which previously sets the content A of the base circumference register to l/A when the sign storage means stores a negative sign, and the arithmetic result of the second arithmetic means is A raised to the B power. A calculation method that is characterized by controlling so that . 2. In the 1-power calculation that calculates the B power of the numerical value A (where B is an integer), an exponent register for storing the exponent B as a pure binary code, a means for storing the sign of the exponent, and the above numerical value A a base circle register for storing , a means for sequentially determining whether the bit content of the exponent register is 11" or 10" from the lower bit, and a means for determining whether the bit content of the exponent register is 11" or 10"; a second calculation means that sequentially multiplies the results of the calculation to obtain the multiplication result; and if the sign storage means stores a negative sign, the a third calculation means for obtaining the reciprocal of the multiplication result by the second calculation means;
A power calculation method characterized in that the calculation result of the calculation means is controlled to be A raised to the B power.
JP8474876A 1976-07-15 1976-07-15 power calculation method Expired JPS5858697B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP8474876A JPS5858697B2 (en) 1976-07-15 1976-07-15 power calculation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP8474876A JPS5858697B2 (en) 1976-07-15 1976-07-15 power calculation method

Publications (2)

Publication Number Publication Date
JPS5310237A JPS5310237A (en) 1978-01-30
JPS5858697B2 true JPS5858697B2 (en) 1983-12-27

Family

ID=13839303

Family Applications (1)

Application Number Title Priority Date Filing Date
JP8474876A Expired JPS5858697B2 (en) 1976-07-15 1976-07-15 power calculation method

Country Status (1)

Country Link
JP (1) JPS5858697B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS57211643A (en) * 1981-06-22 1982-12-25 Fujitsu Ltd Power calculating device
WO2021171881A1 (en) * 2020-02-26 2021-09-02 Ngkエレクトロデバイス株式会社 Package

Also Published As

Publication number Publication date
JPS5310237A (en) 1978-01-30

Similar Documents

Publication Publication Date Title
JPH04127364A (en) Product sum calculating device
JPS5858697B2 (en) power calculation method
US4158889A (en) Calculator for calculating ax with the base a of any positive number by calculating common logarithm of a
JPS5858696B2 (en) power calculation method
JP2578482B2 (en) Floating point arithmetic unit
JP3517162B2 (en) Division and square root arithmetic unit
US7243119B1 (en) Floating point computing unit
JPH0225924A (en) Floating point arithmetic processor
JPH01161437A (en) Divider
JP2951685B2 (en) Fixed-point arithmetic unit
JP3460780B2 (en) Numerical arithmetic unit
JPH0585924B2 (en)
JPH08147146A (en) Division arithmetic operation device
JP3074910B2 (en) Division device
JP2519288B2 (en) Multiplier / divider
JP3551291B2 (en) Serial numerical operation device
JPH06301710A (en) Method and device for double precision product-sum operation
JPH1185471A (en) Operation method and arithmetic unit
JP2002032215A (en) Decimal data dividing method and its program recording medium
JPH0690176A (en) Binary/decimal conversion circuit
JP3277497B2 (en) Divider
JPS63254525A (en) Dividing device
CN117270813A (en) Arithmetic unit, processor, and electronic apparatus
JP2003030159A (en) Square root sign display controlling device, its method and program
JP2005031848A (en) Method, program, and device for floating point arithmetic operation