JPS5939773B2 - Logarithmic function calculation method - Google Patents
Logarithmic function calculation methodInfo
- Publication number
- JPS5939773B2 JPS5939773B2 JP976577A JP976577A JPS5939773B2 JP S5939773 B2 JPS5939773 B2 JP S5939773B2 JP 976577 A JP976577 A JP 976577A JP 976577 A JP976577 A JP 976577A JP S5939773 B2 JPS5939773 B2 JP S5939773B2
- Authority
- JP
- Japan
- Prior art keywords
- register
- storage means
- instruction
- calculation
- logarithmic
- 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
Links
- 238000004364 calculation method Methods 0.000 title claims description 18
- 230000006870 function Effects 0.000 claims description 10
- 238000000034 method Methods 0.000 description 4
- 101100524639 Toxoplasma gondii ROM3 gene Proteins 0.000 description 3
- 238000007781 pre-processing Methods 0.000 description 3
- 238000007796 conventional method Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000001343 mnemonic effect Effects 0.000 description 1
Landscapes
- Complex Calculations (AREA)
Description
【発明の詳細な説明】
本発明は計算機の対数関数の演算方式に関し、特に任意
正数xに対する10を底とする対数関数kg10Xを演
算する方式に関するものである従来、10を底とする対
数関数log1oXを演算する方式として代表的なもの
に、例えばln(1+Y)=Y−Y2/ 2+Y3/
3 +・・・・・・+(−1)n−IYn/n +・・
・・・・ (1)ただし、0≦Y<1で表わされる近似
式を用いてまず自然対数lnXを求め、しかる後にその
結果を1n10=2.30258509・・・・・・で
除算し、その商をlog1oXの関数値とするものがあ
る。DETAILED DESCRIPTION OF THE INVENTION The present invention relates to a calculation method for a logarithmic function in a computer, and more particularly to a method for calculating a base 10 logarithmic function kg10X for an arbitrary positive number x. A typical method for calculating log1oX is, for example, ln(1+Y)=Y-Y2/ 2+Y3/
3 +...+(-1)n-IYn/n +...
(1) However, first find the natural logarithm lnX using the approximate formula expressed as 0≦Y<1, then divide the result by 1n10=2.30258509... There is one in which the quotient is a function value of log1oX.
しかしながら、この方式によると(1)式を適用するに
あたつては、0≦Y<1の制限があり、このため種々の
前処理を必要とするという欠点があつた。本発明の目的
は従来の方式に比べて前処理のみならず全体的な処理が
少なくしかも簡単で従つて演算速度も速い対数関数の演
算方式を提供することにある。However, according to this method, when applying equation (1), there is a restriction that 0≦Y<1, and therefore various pre-processing is required. An object of the present invention is to provide a logarithmic function calculation method that requires less preprocessing and overall processing than conventional methods, is simpler, and therefore has faster calculation speed.
本発明の別の目的は高精度の演算結果が得られる対数関
数の演算方式を提供することにある。Another object of the present invention is to provide a logarithmic function calculation method that provides highly accurate calculation results.
通常、対数関数等を含む科学技術計算を取り扱う計算機
における内部データは正規化された固定d−B5l点表
示された構造を有する。これを数式により表現すれば、
x=x×10N(2)
ただし、】≦1x1<10、、N=整数
となる。Normally, internal data in a computer that handles scientific and technical calculations, including logarithmic functions, etc., has a structure in which normalized fixed dB5l points are displayed. Expressing this mathematically, we get
x=x×10N(2) However, ]≦1x1<10, N=integer.
(1式においてxが仮数部でありNが指数部である。す
なわち、内部データは仮数部xと指数部Nとを独立して
持つている。本発明はこのデータ構造に着目し入力され
る真数データの仮数部と指数部とに別処理を施して対数
関数値を得ようとするものである。(In Equation 1, x is the mantissa part and N is the exponent part. In other words, the internal data has the mantissa part x and the exponent part N independently.The present invention focuses on this data structure and inputs This method attempts to obtain a logarithmic function value by separately processing the mantissa and exponent parts of antilog data.
入力される真数値X&刻時式で表わされる。It is expressed as an input true value X & clock time expression.
(2)式において真数X>0であるので、x>0である
。(2)式の両辺の対数をとると、が成立する。Since the antilog number X>0 in equation (2), x>0. By taking the logarithm of both sides of equation (2), the following holds true.
右辺のNは(2)式の指数部Nであり、整数値である。
一方、1Cg10Xの項は1≦o〈10であるので1〉
1Cg10X≧0すなわち小数値であることがわかる。
すなわち、被演算数Xの指数部Nをそのまま演算結果の
整数部とすべく処理し、他方被演算数Xの仮数部xにつ
いての対数値を求めてこれを演算結果の小数部とすべく
処理することによつて、被演算数Xに対する対数関数値
を容易に求めることができる。N on the right side is the exponent part N of equation (2) and is an integer value.
On the other hand, the term 1Cg10X is 1≦o<10, so 1>
It can be seen that 1Cg10X≧0, that is, it is a decimal value.
That is, the exponent part N of the operand X is processed as it is to be the integer part of the operation result, and the logarithm value of the mantissa part x of the operand X is calculated and processed to be the decimal part of the operation result. By doing so, the logarithmic function value for the operand X can be easily obtained.
しかも仮数部Xは1≦x〈10であるので、例えばHa
stingsの近似公式(Hastings著、竹内均
訳、東京図書1973年発行の『電子計算機のための近
似計算法』の129頁から131頁参照)を用いれば、
わずかの処理のみで1(GlOXが求まる。Moreover, since the mantissa part X is 1≦x<10, for example, Ha
If we use Stings' approximation formula (see pages 129 to 131 of "Approximate Calculation Methods for Electronic Computers" by Hastings, translated by Hitoshi Takeuchi, published by Tokyo Tosho in 1973),
1 (GlOX can be found with only a few steps.
次に図面を用いて本発明の一実施例を説明する。Next, one embodiment of the present invention will be described using the drawings.
第1図は本発明を実施するためのハードウエアを示した
ものである。図において、1aと1bとを含む部分は最
終的に演算結果が格納される循環保持型のZレジスタ、
2は循環保持型のwレジスタである。Zレジスタは通常
はデータ線C,bを通じて保持されているが、右シフト
命令が発生すると最下位桁(4ビツト)1bを除いたデ
ータパスA,bが開き一桁右シフトを行う。3は真数X
として入力される数値の仮数部と指数部とを別処理する
命令が格納されている読み出し専用メモリ(以下ROM
と称す)、4はROM3の番地を逐次指定するアドレス
レジスタ(以下ARと称す)、5はROM3の出力を解
読する命令デコーダ(以下1Dと称す)、G1〜G5は
ID5の出力Inst.により開閉するゲート、6はZ
レジスタあるいはwレジスタの処理すべき桁を指定する
タイミングを発生するタイミング発生器、7はwレジス
タの内容に゛1゛を10進加算するための加算回路、8
はZレジスタの内容が1t01であるかどうかを判断じ
O゛であればその出力でAR4を修飾する判定回路であ
る。FIG. 1 shows the hardware for implementing the invention. In the figure, the part including 1a and 1b is a circular holding type Z register in which the operation result is finally stored;
2 is a circular holding type w register. The Z register is normally held through data lines C and b, but when a right shift command occurs, data paths A and b excluding the least significant digit (4 bits) 1b are opened and a one-digit right shift is performed. 3 is an antilogous number
Read-only memory (hereinafter referred to as ROM) stores instructions for separately processing the mantissa and exponent parts of a numerical value input as
4 is an address register (hereinafter referred to as AR) that sequentially specifies the address of ROM3, 5 is an instruction decoder (hereinafter referred to as 1D) that decodes the output of ROM3, and G1 to G5 are outputs Inst. Gate that opens and closes by, 6 is Z
A timing generator that generates timing to specify the digit to be processed in the register or w register; 7 is an adder circuit for adding 1 in decimal to the contents of the w register; 8
is a determination circuit that determines whether the contents of the Z register are 1t01, and if it is O, modifies AR4 with its output.
9はZレジスタの内容を左シフトするための1桁分(4
ビット)のレジスタ、10はwレジスタの内容を左シフ
トするための1桁分(4ビツト)のレジスタで、左シフ
ト命令が発生すると一桁分余計に循環するためレジスタ
1あるいは2は左シフトされる。9 is one digit (4) to shift the contents of the Z register to the left.
Register 10 (bit) is a 1-digit (4-bit) register for shifting the contents of the w register to the left.When a left shift instruction occurs, register 1 or 2 is shifted to the left because one additional digit is circulated. Ru.
11は10を底とする対数値を演算するための対数演算
器である。Reference numeral 11 denotes a logarithm calculator for calculating logarithmic values having a base of 10.
Zレジスタ1a,1b.Wレジスタ2はそれぞれ第3図
1の如くD1〜D8の8桁(32ビツ(へ)より構成さ
れ、このうちD1〜D6が仮数データ格納部(それぞれ
二ーモニツクZM,WMで表わす)またD7,D8が指
数データ格納部(それぞれ二ーモニツクZE,WEで表
わす)である。Z registers 1a, 1b. Each of the W registers 2 is composed of 8 digits (32 bits) D1 to D8 as shown in FIG. D8 is an exponent data storage section (represented by mnemonics ZE and WE, respectively).
第3図1に示すごとく、データの固定小数点位置をD6
として、wレジスタに0.Zレジスタに2X1012の
データが初期値として格納されている。この初期状態よ
り第2図に示したフローチヤートに従つて10g10(
2X1012)を求めよう。以下、第2図のステツプ1
から順に説明する。(ステツプ1) Zレジスタの仮数
データをwレジスタに転送するためZM+WMの命令が
出される。As shown in Figure 3, the fixed point position of the data is D6.
, 0. is written to the w register. Data of 2×1012 is stored in the Z register as an initial value. From this initial state, 10g10(
2X1012). Below is step 1 in Figure 2.
The explanation will be given in order. (Step 1) An instruction ZM+WM is issued to transfer the mantissa data of the Z register to the w register.
ROM3の出力はID5で解読される。ID5はその出
力によつてタイミング発生器6にD,〜D6に相当する
タイミングを発生させると同時にゲートG3およびG4
を開かせる。従つてZMの内容は信号線eを通じてwレ
ジスタ2のWMに転送される。第3図2はこのステツプ
1の命令が実行された後の各レジスタの内容を表わしw
レジスタには2X10レが格納されていることになる。
(ステツプ2) 10g10W+Wなる命令が出される
。すなわち、wレジスタ2の内容を入力とする対数演算
を行うとともにこの演算結果を再びWレジスタに格納す
る。このステツプにおけるデータの流れは、2→G5→
k→11→n→G4→2である。第3図3はこのステツ
プ2の命令が実行された後の各レジスタの内容を表わし
、データの小数点がD6に固定されているのでWレジス
タには10g102−0.30103が格納されている
ことになる。(ステツプ3) Wの仮数部を再びZへ移
すためWM−+ZMなる命令を実行する。The output of ROM3 is decoded by ID5. ID5 uses its output to cause the timing generator 6 to generate timings corresponding to D, to D6, and at the same time gates G3 and G4.
to open. Therefore, the contents of ZM are transferred to WM of w register 2 through signal line e. Figure 3 2 shows the contents of each register after the step 1 instruction is executed.
This means that 2×10 rays are stored in the register.
(Step 2) The command 10g10W+W is issued. That is, a logarithmic operation is performed using the contents of the w register 2 as input, and the result of this operation is stored in the W register again. The data flow in this step is 2→G5→
k→11→n→G4→2. Figure 3 shows the contents of each register after the step 2 instruction is executed.Since the decimal point of the data is fixed at D6, 10g102-0.30103 is stored in the W register. Become. (Step 3) In order to transfer the mantissa part of W to Z again, execute the instruction WM-+ZM.
このステツプにおけるデータの流れは、2→G5→j+
G1→1である。第3図4にこのステツプ3の命令が実
行された後の各レジスタの内容を示す。(ステツプ4)
ZE=0?という判定命令が出される。The data flow in this step is 2→G5→j+
G1→1. FIG. 3 shows the contents of each register after the step 3 instruction is executed. (Step 4)
ZE=0? A judgment order is issued.
ZEの内容がO、すなわち整数部が存在しない場合、こ
れで演算は終了である。Oでない場合と区別するために
、判定回路8によつてZEの内容がOであるかを判定す
る。この時のデータの流れは、1→G3→d→8である
。Oであると判定回路8よりhを通じアドレスレジスタ
4を修飾し演算終了ルーチンヘアドレスを設定する。(
ステツプ5) ZM−+LSなる命令が出される。ZE
の内容がOでない場合整数部が存在するため、Zレジス
タの仮数部すなわち小数部データとZEの内容を結びつ
けるためにZMを1桁左シフトする。このステツプにお
けるデータの流れは、1→G3→f→9→g→G1→1
である。第3図4が左シフト前、第3図5がシフト後の
レジスタの内容である。(ステツプ6) ZD8=0?
という判定命令が出される。If the content of ZE is O, that is, there is no integer part, the operation is finished. In order to distinguish from the case where ZE is not O, the determination circuit 8 determines whether the content of ZE is O. The data flow at this time is 1→G3→d→8. If it is O, the determination circuit 8 modifies the address register 4 through h and sets the address to the calculation end routine. (
Step 5) A command ZM-+LS is issued. ZE
If the content of is not O, an integer part exists, so ZM is shifted to the left by one digit in order to link the mantissa part, that is, the decimal part data of the Z register, and the content of ZE. The data flow in this step is 1→G3→f→9→g→G1→1
It is. FIG. 3 4 shows the contents of the register before the left shift, and FIG. 3 5 shows the contents of the register after the shift. (Step 6) ZD8=0?
A judgment order is issued.
ZE..の内容が演算結果の整数部であるため、正規化
するためにZEの内容をZMとともに右シフトし仮数部
へ移す必要がある。この場合、ZEが2桁ならば2桁、
1桁(ZD8=0)ならば1桁の右シフトが必要であり
、その区別をつけるためZD8=Oの判定をしOならば
ステツプ9ヘアドレスを移す。(ステツプ7および8)
Z→RSなる命令によりzを右シフトする。ZE. .. Since the content of ZE is the integer part of the operation result, it is necessary to shift the content of ZE to the right together with ZM and transfer it to the mantissa part in order to normalize it. In this case, if ZE is 2 digits, 2 digits,
If it is 1 digit (ZD8=0), a 1 digit right shift is required, and in order to distinguish between them, it is determined that ZD8=O, and if it is O, the address is moved to step 9. (Steps 7 and 8)
Shift z to the right by the command Z→RS.
このときのデータの流れは、1a−+G2→a→b→G
1→1aである。同時にWE+14WE.なる命令によ
りシフト回数をWEに記憶するためにWEに゛1゛を加
算する。このときのデータの流れは、2→G5→sぅ7
ぅT4G4→2であり、第3図6がその結果である。こ
のステツプ7、8はZD8=0の時は実行されない。(
ステツプ9) ステツブ7と同じ動作をする。The data flow at this time is 1a-+G2→a→b→G
1→1a. At the same time WE+14WE. 1 is added to WE in order to store the number of shifts in WE. The data flow at this time is 2 → G5 → s7
T4G4→2, and FIG. 36 is the result. Steps 7 and 8 are not executed when ZD8=0. (
Step 9) Perform the same operation as step 7.
第3図7がその結果を表わし、Zレジスタには1.23
010、WEにはその指数部01が格納されている。(
ステツプ10) WE→ZEなる命令が出される。Figure 3.7 shows the result, and the Z register contains 1.23.
The exponent part 01 is stored in 010 and WE. (
Step 10) A command WE→ZE is issued.
WEに格納されているデータをZEに転送し、Zレジス
タに10g10(2X1012)の演算結果として1.
23010X1001が格納される。この状態を第3図
8に示す。以上の説明から明らかなように、本発明によ
れば前処理のみならず全体的な処理が従来方式に比べて
極めて少なくかつ簡単で従つて演算速度も速いという効
果を有する。The data stored in WE is transferred to ZE, and 1.
23010X1001 is stored. This state is shown in FIG. 38. As is clear from the above description, the present invention has the effect that not only the preprocessing but also the overall processing is extremely small and simple compared to the conventional method, and therefore the calculation speed is high.
第1図は本発明を実施するためのハードウエアの一例を
示したプロツク図、第2図は本発明の演算方式のフロー
チヤートを示した図、第3図1〜8は第2図のフローチ
ヤートの8時点におけるZレジスタおよびWレジスタの
内容を示した図である。
1aおよび1b・・・・・・最終的に演算結果が格納さ
れるZレジスタ、2・・・・・・Wレジスタ、3・・・
・・・真数Xとして入力される数値の仮数部と指数部と
を別処理する命令が格納されている読み出し専用メモリ
(ROM)、4・・・・・・アドレスレジスタ(AR)
、5・・・・・倫令デコーダ(ID)、6・・・・・・
タイミング発生器、7・・・・・・Wレジスタの内容に
゛1゛を加算するための加算回路、8・・・・・・判定
回路、9および10・・・・・・左シフト用の一桁分(
4ビツト)のレジスタ、11・・・・・・10を底とす
る対数値を演算するための対熱演算器、G1〜G5・・
・・・・ゲート。Figure 1 is a block diagram showing an example of hardware for implementing the present invention, Figure 2 is a flowchart of the calculation method of the present invention, and Figures 1 to 8 are the flowchart of Figure 2. FIG. 7 is a diagram showing the contents of the Z register and the W register at eight points in the chart. 1a and 1b... Z register where the calculation result is finally stored, 2... W register, 3...
. . . Read-only memory (ROM) that stores instructions for separately processing the mantissa and exponent parts of the numerical value input as the true number X, 4 . . . Address register (AR)
, 5... Ethics decoder (ID), 6...
Timing generator, 7...addition circuit for adding 1 to the contents of the W register, 8...judgment circuit, 9 and 10...for left shift One digit (
4-bit) register, 11... Heat calculation unit for calculating logarithmic values with base 10, G1 to G5...
····Gate.
Claims (1)
0Xと表わされる対数関数の演算方式において、演算結
果を格納するための演算結果格納手段と、10を底とす
る対数値を演算するための演算手段と、上記真数として
入力される数値の仮数部と指数部とを別処理する命令が
格納されている命令格納手段とを備え、上記命令格納手
段の命令により、上記仮数部に対しては上記演算手段に
対数値を演算させ該対数値を上記演算結果の小数部とし
て上記演算結果格納手段に格納させるが、上記指数部に
対しては上記演算手段に演算を行なわせることなく上記
演算結果の整数部として上記演算結果格納手段に格納さ
せるようにしたことを特徴とする対数関数の演算方式。1 Log_1_ with arbitrary positive number X as an antilog number and base 10
In the calculation method of the logarithmic function expressed as 0X, a calculation result storage means for storing the calculation result, a calculation means for calculating the logarithmic value having a base of 10, and a mantissa of the numerical value input as the above-mentioned antilog number. an instruction storage means storing an instruction for separately processing the exponent part and the exponent part; the instruction storage means causes the arithmetic means to calculate a logarithmic value for the mantissa part according to the instruction of the instruction storage means; The decimal part of the arithmetic result is stored in the arithmetic result storage means, but the exponent part is stored in the arithmetic result storage means as an integer part of the arithmetic result without being operated by the arithmetic means. A calculation method for logarithmic functions characterized by the following.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP976577A JPS5939773B2 (en) | 1977-02-02 | 1977-02-02 | Logarithmic function calculation method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP976577A JPS5939773B2 (en) | 1977-02-02 | 1977-02-02 | Logarithmic function calculation method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPS5395542A JPS5395542A (en) | 1978-08-21 |
| JPS5939773B2 true JPS5939773B2 (en) | 1984-09-26 |
Family
ID=11729355
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP976577A Expired JPS5939773B2 (en) | 1977-02-02 | 1977-02-02 | Logarithmic function calculation method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPS5939773B2 (en) |
-
1977
- 1977-02-02 JP JP976577A patent/JPS5939773B2/en not_active Expired
Also Published As
| Publication number | Publication date |
|---|---|
| JPS5395542A (en) | 1978-08-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US5991785A (en) | Determining an extremum value and its index in an array using a dual-accumulation processor | |
| JPH11154114A (en) | System and method for table look-up using architecture of plural data fetching | |
| JPH05250146A (en) | Arithmetic operation circuit executing integer involution processing | |
| JP3723115B2 (en) | Single instruction multiple data processing | |
| JPS5939773B2 (en) | Logarithmic function calculation method | |
| JP4728392B2 (en) | Large number multiplication method and device | |
| JPH0585924B2 (en) | ||
| JPS63111535A (en) | Data processor | |
| JPS6029409B2 (en) | Trigonometric function calculation device | |
| JP2972326B2 (en) | Square root calculator | |
| JP2705162B2 (en) | Arithmetic processing unit | |
| JPS6259828B2 (en) | ||
| JPH0721760B2 (en) | Digital arithmetic circuit | |
| JP2605792B2 (en) | Arithmetic processing unit | |
| JPS5944656B2 (en) | Integration method of digital differential analyzer | |
| JP3074910B2 (en) | Division device | |
| JP2624738B2 (en) | Rounding method | |
| JP3088956B2 (en) | Arithmetic unit | |
| JPS63254525A (en) | division device | |
| JP3523407B2 (en) | Information processing equipment | |
| JPH02181821A (en) | Arithmetic device | |
| JP2000222174A (en) | Signal processor and product sum computing element with rounding function used for the same | |
| JPH0215089B2 (en) | ||
| JPS59161730A (en) | Pipeline computing element | |
| JPH02242426A (en) | Division system for digital signal processor |