JPH0272480A - Mean value arithmetic means - Google Patents

Mean value arithmetic means

Info

Publication number
JPH0272480A
JPH0272480A JP22362388A JP22362388A JPH0272480A JP H0272480 A JPH0272480 A JP H0272480A JP 22362388 A JP22362388 A JP 22362388A JP 22362388 A JP22362388 A JP 22362388A JP H0272480 A JPH0272480 A JP H0272480A
Authority
JP
Japan
Prior art keywords
value
memory
digital
stored
remainder
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP22362388A
Other languages
Japanese (ja)
Inventor
Satoshi Miura
智 三浦
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.)
Fuji Electric Co Ltd
Original Assignee
Fuji Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fuji Electric Co Ltd filed Critical Fuji Electric Co Ltd
Priority to JP22362388A priority Critical patent/JPH0272480A/en
Publication of JPH0272480A publication Critical patent/JPH0272480A/en
Pending legal-status Critical Current

Links

Landscapes

  • Complex Calculations (AREA)

Abstract

PURPOSE:To easily make the error of a mean value into a small value without generating an overflow by dividing a digital numeric value with a prescribed coefficient, and providing two memories which respectively store a quotient value as the result of a division and a remainder value. CONSTITUTION:The digital numeric value is divided by a prescribed coefficient A, the quotient value as the result of the division and the remainder value are allocated to two types of memories 1 and 2, and the added result between the remainder value and the next digital numeric value is divided again by the prescribed coefficient A. Further, the present quotient value and the last quotient value are added to be stored and updated to the first memory 1, the present remainder value is stored and updated to the second memory 2 instead of the last remainder, and the processings are respectively repeated. Thus, the overflow of the memory can be prevented, rounding-up and rounding-off, etc., are not executed even if the value is divided by the prescribed value, the error is not generated at all until the division by means of the total number (n) for the output of the mean value, and the error can be easily suppressed to the small value <= a decimal point.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 この発明は、ディジタル数値制御装置の演算方式に係り
、特にディジタル数値のオーバーフローを防止して精度
の良い平均値を得るための演算方式に関する。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to an arithmetic method for a digital numerical control device, and particularly to an arithmetic method for preventing overflow of digital numerical values and obtaining a highly accurate average value.

〔従来の技術〕[Conventional technology]

従来、ディジタル数値制御装置における平均値の演算方
式として、全数のディジタル数値を加算した後に全ディ
ジタル数値の個数で除算して平均値を求める方式がある
が、この方式では、全数のディジタル数値を加算する時
に、場合によってはメモリ容量を越えてオーバーフロー
を生じ、計算不能に陥る可能性がある。これを防止する
ために、加算するディジタル数値の個数、すなわち、サ
ンプリング数を制限して平均値を求める方式がある。
Conventionally, as a method for calculating the average value in a digital numerical control device, there is a method of adding all the digital values and then dividing by the number of all digital values to obtain the average value. When doing so, in some cases, the memory capacity may be exceeded and an overflow may occur, making calculations impossible. In order to prevent this, there is a method of determining the average value by limiting the number of digital numerical values to be added, that is, the number of samplings.

例えば、メモリ容量を越えないサンプリング数をに個と
すると、先ず、第1番目から1(番目までのディジタル
数値を加算した後、サンプリング数にで除算して平均値
を求める0次いで、(k±1)番目のディジタル数値と
、この平均値に<k−1>を掛算した値とを加算して、
再びサンプリング数にで除算することを、(k+1)番
目から最後のn番目のディジタル数値まで繰返して平均
値を求める方式である。
For example, if the number of samplings that does not exceed the memory capacity is , first add the digital values from 1st to 1(th), then divide the number of samples by 0 to obtain the average value, then (k± 1) Add the th digital value and the value obtained by multiplying this average value by <k-1>,
This method calculates the average value by repeating dividing by the number of samples again from the (k+1)th to the last nth digital value.

〔発明が解決しようとする課題〕[Problem to be solved by the invention]

しかしながら、前述した全ディジタル数を加算してから
平均値を求める演算方式によれば、十分な桁数を確保し
てオーバーフローを生じないようにするには、大きなメ
モリ容量を必要とし、コスト高を招き、さらにサンプリ
ング数を制限して平均値を求める演算方式では、精度が
悪くなるという問題点があった。
However, according to the arithmetic method described above that adds all the digital numbers and then calculates the average value, in order to ensure a sufficient number of digits and prevent overflow, a large memory capacity is required and the cost is high. Furthermore, the calculation method in which the average value is determined by limiting the number of samples has the problem of poor accuracy.

そこで、本発明の目的は、ディジタル数値演算装置にお
いて、メモリのオーバーフローを防止すると共に誤差を
小数点以下の小さな値に抑えることのできる平均値の演
算方式を提供するにある。
SUMMARY OF THE INVENTION Therefore, an object of the present invention is to provide an average value calculation method that can prevent memory overflow and suppress errors to a small value below the decimal point in a digital numerical calculation device.

〔課題を解決するための手段〕[Means to solve the problem]

本発明に係る平均値の演算方式は、第1番目のディジタ
ル数値と第2番目のディジタル数値とを加算した値に対
し所定係数を用いて除算し、この除算結果の商の値を第
1のメモリに記憶し、剰余の値を第2のメモリに記憶し
た後、 第3番目のディジタル数値と前記第2のメモリに記憶さ
れた数値とを加算し、加算結果を前記所定係数により除
算し、この除算結果の商の値と前記第1のメモリに記憶
された数値とを加算した値を第1のメモリに記憶される
数値としてその記憶数値を更新すると共に剰余の値を第
2のメモリに記憶される数値としてその記憶数値を更新
し、 以下、第4番目のディジタル数値から第n番目のディジ
タル数値まで同様にして第1のメモリと第2のメモリに
記憶される数値を順次更新し、 第n番目のディジタル数値によって更新された第1のメ
モリに記憶された数値に対しディジタル数値の全個数n
により除算した後、前記所定係数を掛算し、 この掛算結果と、第n番目のディジタル数値により更新
された第2のメモリに記憶された数値を前記個数nによ
り除算した値とを加算することを特徴とする。
The average value calculation method according to the present invention is to divide the sum of the first digital value and the second digital value by a predetermined coefficient, and then divide the value of the quotient of this division result into the first value. After storing the remainder value in a memory and storing the remainder value in a second memory, adding a third digital numerical value and the numerical value stored in the second memory, and dividing the addition result by the predetermined coefficient; The value obtained by adding the quotient value of this division result and the numerical value stored in the first memory is set as the numerical value stored in the first memory, and the stored numerical value is updated, and the value of the remainder is stored in the second memory. The stored numerical value is updated as the numerical value to be stored, and thereafter, the numerical values stored in the first memory and the second memory are sequentially updated in the same manner from the fourth digital numerical value to the nth digital numerical value, The total number n of digital values for the value stored in the first memory updated by the nth digital value
After dividing by, the predetermined coefficient is multiplied, and this multiplication result is added to the value obtained by dividing the numerical value stored in the second memory updated by the n-th digital numerical value by the number n. Features.

〔作用〕[Effect]

本発明に係る平均値の演算方式によれば、ディジタル数
値を所定係数で除算し、除算した結果の商の値と剰余の
値とを2種類のメモリに割付け、この剰余の値と次のデ
ィジタル数値との加算結果を再び所定係数にて除算し、
この今回の商の値と、前回の商の値とを加算して第1の
メモリに記憶更新すると共に、今回の剰余の値を前回の
剰余の代りに第2のメモリに記憶更新することをそれぞ
れ繰り返すことによって、各メモリに記憶されるディジ
タル数値は桁数の小さい数値を取板うこととなるため、
従来のように全ディジタル数値をそのまま加算した場合
に生じたメモリのオーバーフローを防止できると共に所
定係数で除算しても商の値と剰余の値とをそれぞれのメ
モリに割付けて、切り上げ、切り下げ等は行わないため
、平均値を出すための全個数nによる除算までは同等誤
差は生じず、真の平均値との誤差はメモリの有効桁数に
より決まるので、容易に小数点以下の小さな値に誤差を
抑えることができる。
According to the average value calculation method according to the present invention, a digital numerical value is divided by a predetermined coefficient, the quotient value and the remainder value of the division result are allocated to two types of memories, and this remainder value and the next digital Divide the addition result with the numerical value again by the predetermined coefficient,
The current quotient value and the previous quotient value are added together and stored and updated in the first memory, and the current remainder value is stored and updated in the second memory instead of the previous remainder. By repeating each, the digital numbers stored in each memory will be those with a small number of digits, so
It is possible to prevent memory overflow that occurs when all digital values are added as they are, as in the past, and even when dividing by a predetermined coefficient, the quotient value and remainder value are assigned to respective memories, and rounding up or down can be avoided. Therefore, no equivalent error occurs until division by the total number n to obtain the average value, and the error from the true average value is determined by the number of significant digits in the memory, so it is easy to add errors to small values below the decimal point. It can be suppressed.

〔実施例〕〔Example〕

次に、本発明に係る平均値の演算方式の実施例につき、
添付図面を参照しながら以下詳細に説明する。
Next, regarding an embodiment of the average value calculation method according to the present invention,
A detailed description will be given below with reference to the accompanying drawings.

第1図は、本発明の一実施例を示し、平均値の演算方式
の計算手順の概要を示す、第1図においてり、〜D、は
ディジタル数値であり、nは全ディジタル数値の個数、
Aは所定係数である。所定係数Aはnよりも大きく、好
ましくはディジタル数値のAによる除算の商の値が少く
とも1桁以上小さくなるような値で、この商の値をn個
加算してもメモリがオーバーフローしないような値に選
ぶのが良い0例えば、10’とか104といった値であ
る。先ず、第1番目のディジタル数値D1と第2番目の
ディジタル数値D2とを加算しくf旦し、D、とD2を
カロ算してもオーバーフローしない数値とする)、この
加算結果を所定係数Aにより除算する。除算結果の商の
値はメモリ1に書込み、剰余の値はメモリ2に書込むの
で、切り上げ、切り下げ等は行う必要がない0次いで、
第3番目のディジタル数値り、とメモリ2に書込まれて
いる剰余の値とを加算した後、再び所定係数Aで除算す
る。
FIG. 1 shows an embodiment of the present invention and shows an overview of the calculation procedure of the average value calculation method. In FIG. 1, ~D is a digital value, n is the number of all digital values,
A is a predetermined coefficient. The predetermined coefficient A is larger than n, preferably a value such that the value of the quotient when the digital numerical value is divided by A is at least one digit smaller, and the value is such that the memory will not overflow even if n values of this quotient are added. For example, a value such as 10' or 104 is a good value to choose. First, add the first digital value D1 and the second digital value D2, and set D and D2 to a value that will not overflow even if you calculate them), and then calculate this addition result by a predetermined coefficient A. Divide. The quotient value of the division result is written to memory 1, and the remainder value is written to memory 2, so there is no need to round up or down.
After adding the third digital value and the remainder value written in the memory 2, division is again performed by the predetermined coefficient A.

今回の商の値と、メモリ1に書込まれている前回の商の
値と加算した値を、今回値としてメモリ1の値Xに更新
する。また、今回の剰余の値をメモリ2の(fiyとし
て書き換える。
The value obtained by adding the current quotient value and the previous quotient value written in the memory 1 is updated to the value X in the memory 1 as the current value. Also, the current remainder value is rewritten as (fiy) in memory 2.

以下、−点鎖線10で囲んだ一連の計算手順を最後のデ
“イジタル数値り、まで繰り返した後、メモリ1の値を
全ディジタル数値の個数nで除算し、所定係数Aを掛算
する。一方、メモリ2の値を同じくnで除算し、この除
算結果と前記所定係数Aをfl)ユした結果とを加算す
ると、n個のディジタル数り、〜D、の平均値りが得ら
れる。この得られた平均領置と、ディジタル数値D1〜
D、を全部加算し、全数nで除算(オーバーフローはし
ないものとする)して得られる真の平均値との間の誤差
は、メモリ1とメモリ2の有効桁数により制限されるだ
けであり、有効桁数が十分大きければ誤差は限り無く零
に近くでき、従って、有効桁数を適当な値に選ぶことに
より、誤差を小数点以下に容易に抑制できる。
Hereinafter, after repeating the series of calculation steps enclosed by the dashed line 10 until the last digital value, the value in memory 1 is divided by the total number of digital values n, and multiplied by a predetermined coefficient A. , the value in memory 2 is similarly divided by n, and the result of this division is added to the result obtained by multiplying the predetermined coefficient A, the average value of n digital numbers, ~D, is obtained. The obtained average placement and the digital numerical value D1~
The error between the true average value obtained by adding all D and dividing by the total number n (assuming no overflow) is limited only by the number of significant digits in memory 1 and memory 2. If the number of significant digits is sufficiently large, the error can be infinitely close to zero. Therefore, by selecting an appropriate number of significant digits, the error can be easily suppressed to below the decimal point.

第2図は、本発明の他の実施例である平均値の演算方式
の計算手順を示し、第1図の実施例で述べたディジタル
数値り、とD2を加算する場合に、オーバーフローしな
い値とするという条件を除くための演算方式である。
FIG. 2 shows the calculation procedure of the average value calculation method according to another embodiment of the present invention. This calculation method eliminates the condition that

本実施例では、最初に、メモリ1とメモリ2の値は、そ
れぞれ初期fIiXO、yoとしてオール零の状態にセ
ットする0次いで、第1番目のディジタル数値D1とメ
モリ2のrly 。
In this embodiment, first, the values of memory 1 and memory 2 are set to all zeros as initial fIiXO, yo, respectively. Then, the first digital value D1 and rly of memory 2 are set to zero.

とを加算し、この値を所定係数Aで除算する。This value is divided by a predetermined coefficient A.

商の値はメモリ1の値Xaと加算して、新たにメモリ1
の[Xとして書き換える。一方、剰余の値はメモリ2の
値y0の代りにそのままyとして書き換える。第2番目
のディジタル数値D2からは、前回の値であるメモリ1
の値Xとメモリ2の値yとを用いて、ディジタル数値D
1と同様の一点鎖線30で示した計算手順を最後の第n
番目のディジタル数値まで繰り返す、この後は、メモリ
1とメモリ2のそれぞれの値を第1図の実施例と同様に
計算して平均値が求められる。
The quotient value is added to the value Xa of memory 1, and a new memory 1 is created.
[Rewrite as [X]. On the other hand, the remainder value is rewritten as y instead of the value y0 in memory 2. From the second digital value D2, the previous value, memory 1
Using value X of , and value y of memory 2, digital numerical value D
The calculation procedure shown by the dashed-dotted line 30 similar to 1.
The process is repeated up to the th digital value. After this, each value in memory 1 and memory 2 is calculated in the same manner as in the embodiment of FIG. 1, and an average value is obtained.

この実施例では、メモリ1とメモリ2とを妓初に零にセ
ットしておく点が第1図の実施例と異なるだけであり、
求まる平均値の誤差に関しては同じである。
This embodiment differs from the embodiment shown in FIG. 1 only in that memory 1 and memory 2 are initially set to zero.
The same applies to the error in the average value found.

〔発明の効果〕〔Effect of the invention〕

前述した実施例から明らかなように、本発明によれば、
ディジタル数値を所定係数で除算すると共に除算した結
果の商の値と剰余の値とをそれぞれ記憶するメモリを2
つ用意したので、各メモリに記憶される数値は全個数で
除算するまでは誤差を生じることはなく、取扱うディジ
タル数値も小さいのでオーバーフローも生じない、また
、所定係数と各メモリの有効桁数を適当に選ぶことによ
り、容易に平均値の誤差を小数点以下の小さな値にする
ことができる。
As is clear from the embodiments described above, according to the present invention,
2 memories for dividing a digital numerical value by a predetermined coefficient and storing the quotient value and remainder value of the division result, respectively.
Since the number stored in each memory is divided by the total number, there will be no error until it is divided by the total number, and since the digital numbers handled are small, overflow will not occur. By selecting an appropriate value, it is possible to easily reduce the error in the average value to a small value below the decimal point.

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

第1図は本発明に係る平均値の演算方式の一実施例を示
す計算手順のブロック図、第2図は本発明演算方式の他
の実施例を示す計算手順のブロック図である。 1・・・(商の値の)メモリ 2・・・(剰余の値の)メモリ 10・・・繰り返し計算手順 20・・・初期値の計算手順 30・・・繰り返し計算手順 DI〜D1・・・ディジタル数値 n・・・ディジタル数値の個数 A・・・所定係数 X o + ’j ’・・・初期値(零)X・・・メモ
リ1の数値 y・・・メモリ2の数値
FIG. 1 is a block diagram of a calculation procedure showing one embodiment of the average value calculation method according to the present invention, and FIG. 2 is a block diagram of a calculation procedure showing another embodiment of the calculation method of the present invention. 1... Memory (for quotient value) 2... Memory (for remainder value) 10... Repeat calculation procedure 20... Initial value calculation procedure 30... Repeat calculation procedure DI to D1...・Digital numerical value n... Number of digital numerical values A... Predetermined coefficient X o + 'j'... Initial value (zero) X... Numerical value in memory 1 y... Numerical value in memory 2

Claims (1)

【特許請求の範囲】[Claims] (1)第1番目のディジタル数値と第2番目のディジタ
ル数値とを加算した値に対し所定係数を用いて除算し、
この除算結果の商の値を第1のメモリに記憶し、剰余の
値を第2のメモリに記憶した後、 第3番目のディジタル数値と前記第2のメモリに記憶さ
れた数値とを加算し、加算結果を前記所定係数により除
算し、この除算結果の商の値と前記第1のメモリに記憶
された数値とを加算した値を第1のメモリに記憶される
数値としてその記憶数値を更新すると共に剰余の値を第
2のメモリに記憶される数値としてその記憶数値を更新
し、 以下、第4番目のディジタル数値から第n番目のディジ
タル数値まで同様にして第1のメモリと第2のメモリに
記憶される数値を順次更新し、 第n番目のディジタル数値によって更新された第1のメ
モリに記憶された数値に対しディジタル数値の全個数n
により除算した後、前記所定係数を掛算し、 この掛算結果と、第n番目のディジタル数値により更新
された第2のメモリに記憶された数値を前記個数nによ
り除算した値とを加算することを特徴とする平均値の演
算方式。
(1) Divide the sum of the first digital value and the second digital value by a predetermined coefficient,
After storing the quotient value of this division result in the first memory and storing the remainder value in the second memory, the third digital value and the value stored in the second memory are added. , divide the addition result by the predetermined coefficient, and update the stored numerical value by adding the quotient value of this division result and the numerical value stored in the first memory as a numerical value stored in the first memory. At the same time, the value of the remainder is stored in the second memory and the stored numerical value is updated, and from the fourth digital numerical value to the nth digital numerical value, the first memory and the second digital numerical value are stored in the same manner. The numerical values stored in the memory are updated sequentially, and the total number n of digital numerical values is calculated for the numerical value stored in the first memory updated by the nth digital numerical value.
After dividing by, the predetermined coefficient is multiplied, and this multiplication result is added to the value obtained by dividing the numerical value stored in the second memory updated by the n-th digital numerical value by the number n. Features an average value calculation method.
JP22362388A 1988-09-08 1988-09-08 Mean value arithmetic means Pending JPH0272480A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP22362388A JPH0272480A (en) 1988-09-08 1988-09-08 Mean value arithmetic means

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP22362388A JPH0272480A (en) 1988-09-08 1988-09-08 Mean value arithmetic means

Publications (1)

Publication Number Publication Date
JPH0272480A true JPH0272480A (en) 1990-03-12

Family

ID=16801110

Family Applications (1)

Application Number Title Priority Date Filing Date
JP22362388A Pending JPH0272480A (en) 1988-09-08 1988-09-08 Mean value arithmetic means

Country Status (1)

Country Link
JP (1) JPH0272480A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10848551B2 (en) 2018-08-28 2020-11-24 Fujitsu Limited Information processing apparatus, parallel computer system, and method for control

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10848551B2 (en) 2018-08-28 2020-11-24 Fujitsu Limited Information processing apparatus, parallel computer system, and method for control

Similar Documents

Publication Publication Date Title
US5768170A (en) Method and apparatus for performing microprocessor integer division operations using floating point hardware
CA2225899A1 (en) A method and apparatus for finite field multiplication
JPH0319569B2 (en)
CN1172539A (en) Logarithm/inverse-logarithm converter utilizing truncated taylor series and method of use thereof
US6769006B2 (en) Method and apparatus for calculating a reciprocal
KR920003479B1 (en) Method and apparatus for piecewise curve approximation
JPH0272480A (en) Mean value arithmetic means
JPH0566921A (en) Data shift circuit
US5587940A (en) Non-heuristic decimal divide method and apparatus
Lewis An accurate LNS arithmetic unit using interleaved memory function interpolator
KR940008611B1 (en) Binary floating point arithmetic rounding in conformance with ieee 754-1985 standard
JP2737933B2 (en) Division device
JP2584516B2 (en) Opening calculator
KR100506470B1 (en) Method and hardware for computing reciprocal square root and a storage medium
JP2508286B2 (en) Square root calculator
JPH0585924B2 (en)
JP3616385B2 (en) Divide-by-two unit, multiplier, and program recording medium thereof
JP2960595B2 (en) Digital signal processor
JP3105577B2 (en) Division product multiplier
JPS5872999A (en) Multiplication system employing memory element
US20090292756A1 (en) Large-factor multiplication in an array of processors
JP3078696B2 (en) Reciprocal arithmetic unit
JP2828791B2 (en) A method for quantizing partial sums used in the product-sum operation
JPH0630434B2 (en) Digital Filter
JPH06180640A (en) Device and method for division