JP2606580B2 - Numerical data calculation method - Google Patents

Numerical data calculation method

Info

Publication number
JP2606580B2
JP2606580B2 JP6089603A JP8960394A JP2606580B2 JP 2606580 B2 JP2606580 B2 JP 2606580B2 JP 6089603 A JP6089603 A JP 6089603A JP 8960394 A JP8960394 A JP 8960394A JP 2606580 B2 JP2606580 B2 JP 2606580B2
Authority
JP
Japan
Prior art keywords
numerical data
byte
data
digit
mantissa
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 - Lifetime
Application number
JP6089603A
Other languages
Japanese (ja)
Other versions
JPH06318147A (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.)
Casio Computer Co Ltd
Original Assignee
Casio Computer 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 Casio Computer Co Ltd filed Critical Casio Computer Co Ltd
Priority to JP6089603A priority Critical patent/JP2606580B2/en
Publication of JPH06318147A publication Critical patent/JPH06318147A/en
Application granted granted Critical
Publication of JP2606580B2 publication Critical patent/JP2606580B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【産業上の利用分野】本発明は情報処理における数値デ
ータ演算方法に関する。
FIELD OF THE INVENTION The present invention relates to a numerical value in the information processing de
Data calculation method .

【0002】[0002]

【従来の技術】科学技術計算のような膨大な計算を必要
とせず、多量のデータを入力し、多量のデータを出力す
るような事務上の情報処理(例えば給与計算)では、高
速性の点で不利ではあるが、一般的に2進演算よりも10
進演算が用いられる。10進数値の表現形式としては例え
ばBCDコードを用い、10進1桁を4ビットで表現し、
8ビットより成る1バイトに10進2桁を格納するパック
形式がある。
2. Description of the Related Art In office information processing (for example, payroll calculation) in which a large amount of data is input and a large amount of data is output without requiring an enormous amount of calculation such as scientific calculation, a point of high speed is required. But generally 10 times less than binary arithmetic
Hexadecimal operation is used. As a decimal value representation format, for example, a BCD code is used, and one decimal digit is represented by 4 bits.
There is a packed format in which two decimal digits are stored in one byte of eight bits.

【0003】この方式は10進における切捨や四捨五入2
進演算では誤差となってしまうものもBCD表現では誤
差なくできるので、オフィスにおける演算等の有効数字
桁内での誤差が認められない装置に用いられている。
[0003] This method is used for rounding down or rounding off decimal numbers.
Since an error in the binary operation can be made in the BCD expression without an error, it is used in an apparatus that does not recognize an error in a significant digit, such as an operation in an office.

【0004】従来用いられていた数値データのパック形
式を図5に示す。図5(a) で全8バイトのうち最上位1
バイトが指数部であり、該1バイトの中で1ビットが指
数部符号、7ビットが指数を表現する。基数は10である
から10-127〜10+127の範囲の数値が表現できる。指数部
以外の7バイトのうち上位6 1/2バイトが仮数部であ
り、10進で13桁の有効数字が表現される。小数点は仮数
部の最上位バイト中で上位4ビットと下位4ビットとの
間に固定されている。また最下位 1/2バイトは数値デー
タの符号を表わし、例えば+は1100、−は1101で表わ
す。
FIG. 5 shows a pack format of conventionally used numerical data. In FIG. 5 (a), the most significant one of all eight bytes
The byte is an exponent part, and one bit in the one byte represents an exponent part sign and seven bits represent an exponent. Since the radix is 10, a numerical value in the range of 10 -127 to 10 +127 can be expressed. The upper 61/2 bytes of the 7 bytes other than the exponent are the mantissa, and represent 13 significant digits in decimal. The decimal point is fixed between the upper 4 bits and the lower 4 bits in the most significant byte of the mantissa. The least significant 1/2 byte represents the sign of the numerical data. For example, + represents 1100 and-represents 1101.

【0005】図5(b) のパック例ではバイト毎に実線、
4ビットを破線で区切り、該各4ビットに格納された10
進データを記入してあるが実際にはBCDコード、すな
わち4ビット2進数が格納されている。該例は10進数−
1234.567が −1.234567×103 の形式で表現されたものである。
[0005] In the pack example of FIG.
The four bits are separated by broken lines, and the 10 bits stored in each of the four bits are
Although binary data is written, a BCD code, that is, a 4-bit binary number is actually stored. The example is decimal-
1234.567 is expressed in the form of -1.234567 × 10 3 .

【0006】[0006]

【発明が解決しようとする課題】しかしながら上述のよ
うなパック方式では演算時の桁合せの際に4ビット単位
での左、あるいは右へのシフト操作が必要となる。
However, in the packing method as described above, a shift operation to the left or right in 4-bit units is required at the time of digit alignment at the time of calculation.

【0007】この桁合せ処理について図6のフローチャ
ートを用いて説明する。CPU(図示せず)は、桁合せ
がスタートし、二つの数値データN1 、N2 が入力され
る(S1)と、該データN1 とN2 のそれぞれの指数部
1 、n2 の大小が比較される(S2)。n1 がn2
り大きい場合には、N2 の仮数部が4ビット右へシフト
される(S3)。該シフト操作にはN2 に10-1を乗じた
ことに相当するため、N2 の指数部に1を加えn2 +1
→n2 とする(S4)。再びS2に戻り、指数部の比較
が行なわれ、二つのデータの指数部が一致するまで、S
2からS4までが繰返される。両データの指数部が一致
すると演算処理に移行(S5)する。
The digit alignment processing will be described with reference to the flowchart of FIG. The CPU (not shown) starts digit alignment and inputs two numerical data N 1 and N 2 (S 1). When the two numerical data N 1 and N 2 are input (S 1), the exponents n 1 and n 2 of the data N 1 and N 2 are calculated. The magnitude is compared (S2). If n 1 is greater than n 2 , the mantissa of N 2 is shifted right by 4 bits (S3). Since the shift operation is equivalent to multiplying N 2 by 10 −1 , 1 is added to the exponent part of N 2 and n 2 +1
→ Set to n 2 (S4). Returning to S2, the exponents are compared, and S is repeated until the exponents of the two data match.
Steps 2 to S4 are repeated. When the exponents of the two data match, the process shifts to arithmetic processing (S5).

【0008】逆に数値データN2 の指数部n2 がデータ
1 の指数部n1 より大きい場合には、N2 の仮数部を
4ビット左へシフトし(S3´)、N2 の指数部から1
を減じるためn2 −1→n2 とする(S4´)。ステッ
プ2、3´、4´は該両データの指数部が一致するまで
繰返され、一致すると演算処理に移行(S5)する。
On the contrary, if the exponent part n 2 of the numerical data N 2 is larger than the exponent part n 1 of the data N 1 , the mantissa part of N 2 is shifted to the left by 4 bits (S3 ′), and the exponent of N 2 1 from the department
Is set to n 2 −1 → n 2 (S4 ′). Steps 2, 3 ', and 4' are repeated until the exponents of the two data match, and if they match, the process shifts to arithmetic processing (S5).

【0009】上述の桁合せ処理においては、4ビット単
位での右、または左へのシフト操作が必要である。この
ためハードウェア自体にビットシフト機能が要求され、
しかも指数の差と同じ回数だけ4ビットシフト操作を行
なう必要があり、時間がかかるという問題があった。
In the above-described digit alignment processing, a shift operation to the right or left in units of 4 bits is required. This requires a bit shift function in the hardware itself,
Moreover, it is necessary to perform the 4-bit shift operation the same number of times as the difference between the exponents, which takes a long time.

【0010】本発明の課題は、従来のデータ長(例えば
8バイト)を変更することなく、繁雑なビットシフト操
作を不要にして、桁合せ時間を短縮した数値データ演算
方法を提供することである。
SUMMARY OF THE INVENTION An object of the present invention is to provide a numerical data arithmetic apparatus which does not require a complicated bit shift operation without changing the conventional data length (for example, 8 bytes) and which reduces the digitizing time.
Is to provide a way.

【0011】[0011]

【課題を解決するための手段】本発明の手段は次の通り
である。 2桁のBCDコードを1バイトで表現した複数
バイトからなる仮数と、仮数部の小数点位置の桁を10
0の整数乗を基数とした指数で表わした指数部とにより
数値データを構成し、2つの数値データを演算する際
に、2つの数値データにおける指数部の差を求め、求め
られた差に基づいて上記2つの数値データのうち何れか
一方の数値データにおける仮数部をバイト単位でシフト
して桁合せを行ない、この桁合せ後に上記2つの数値デ
ータを演算するようにしたことを特徴とする。
Means of the present invention are as follows.
It is. Multiple two-digit BCD code expressed in one byte
The mantissa consisting of bytes and the decimal place of the mantissa
With the exponent part expressed as an exponent based on an integer power of 0
When constructing numerical data and calculating two numerical data
To find the difference between the exponents of the two numerical data
Either of the above two numerical data based on the difference
Shift the mantissa part of one numerical data by byte
After the digit alignment, the two numerical data
Data is calculated.

【0012】[0012]

【作用】本発明の数値データ演算方法を用いることによ
り、BCD演算の高速化を図ることができる。
By using the numerical data calculation method of the present invention,
Thus, the speed of the BCD operation can be increased.

【0013】[0013]

【0014】[0014]

【実施例】本発明のデータパック方式の一実施例が図2
である。図は従来の技術の項で説明した図5(b) と同様
10進数−1234.567をパックした例を示す。図5(b) と同
様にバイト区切りを実線、4ビット毎の10進数データを
破線で区切ってある。4ビット毎の10進数データは、実
際にはBCDコード、即ち4ビットの2進数の形式で格
納されている。
FIG. 2 shows an embodiment of the data pack system according to the present invention.
It is. The figure is the same as Fig. 5 (b) explained in the section of the prior art.
Here is an example of packing decimal number-1234.567. As in FIG. 5B, the byte delimiter is divided by a solid line and the decimal data of every four bits is delimited by a broken line. The decimal data of every 4 bits is actually stored in the form of a BCD code, that is, a 4-bit binary number.

【0015】前記図1で説明したように、小数点は最上
位バイト内最上位ビットの左側にあり、基数は100 であ
る。最下位1バイト内最上位ビットにあるデータ符号は
図2では、すなわち1であり、該最下位バイト内で残り
の7ビットが表現する指数が2であることから該数値デ
ータは −.1234567×1002 の形式でパックされていることになる。
As described with reference to FIG. 1, the decimal point is to the left of the most significant bit in the most significant byte, and the radix is 100. In FIG. 2, the data code at the most significant bit in the least significant byte is 1, and the exponent represented by the remaining 7 bits in the least significant byte is 2, so that the numerical data is -.1234567 × It will be packed in 100 2 format.

【0016】次に本発明のデータパック方式に基づく桁
合せ時のビットシフト操作の不要化、すなわちバイト単
位のシフト操作につき、図3の桁合せフローチャートを
用いて説明する。CPU(図示せず)は、桁合せがスタ
ートすると二つの数値データN1 、N2 が入力(ST
1)され、次にN1 の指数部n1 とN2 の指数部n2
の差が求められる(ST2)。
Next, the need for a bit shift operation at the time of digit alignment based on the data pack method of the present invention, that is, the shift operation in byte units, will be described with reference to the digit alignment flowchart of FIG. The CPU (not shown) inputs two numerical data N 1 and N 2 when digit alignment starts (ST).
1) it is, then the difference between the exponent n 2 of the exponent n 1 and N 2 of N 1 is determined (ST2).

【0017】その結果n1 −n2 >0である場合には、
1 とn2 との差に相当するバイト数だけ、すなわち差
が1であれば1バイト、2であれば2バイト、・・・と
いうように、例えばN2 の仮数部を右へシフトさせる。
逆にN1 の仮数部を左へシフトさせてもよい。またn2
−n1 >0である場合には、その差に相当するバイト数
だけN2 の仮数部を左へシフトさせるか、あるいはN1
の仮数部を右へシフトさせる(ST3)。その後に演算
処理へ移行(ST4)するが、前記ST2における指数
部の差が零である場合には直ちに演算処理へ移行(ST
4)することは当然である。
As a result, when n 1 −n 2 > 0,
The mantissa of N 2 is shifted to the right, for example, by the number of bytes corresponding to the difference between n 1 and n 2 , that is, 1 byte if the difference is 1, 2 bytes if the difference is 2, and so on. .
The mantissa of N 1 may be shifted to the left in the opposite. And n 2
If −n 1 > 0, the mantissa of N 2 is shifted to the left by the number of bytes corresponding to the difference, or N 1
Is shifted to the right (ST3). Thereafter, the process proceeds to the operation process (ST4). If the difference between the exponents in ST2 is zero, the process immediately proceeds to the operation process (ST4).
4) It is natural to do.

【0018】上述の桁合せ時のバイトシフト操作は、例
えば図示しないランダムアクセスメモリ(RAM)内部
の数値データ記憶領域内で該数値データの記憶開始アド
レスを示すポインタ位置を変更することによっても実現
できる。図4にRAM内部の数値データ記憶領域の例を
示し、バイト単位のシフト操作を説明する。各アドレス
に1バイトのデータを記憶させると図のように10進2桁
のデータが格納される。数値データ開始アドレスを示す
ポインタが最初P1 にあるとすると、記憶されている現
在の数値データ仮数部は、 .00001234567000 となっている。ポインタ位置を図のP2 に変更すること
により2バイトの左シフトが行なわれ、その結果の仮数
部は前記図2におけると全く同様となる。
The above-described byte shift operation at the time of digit alignment can also be realized by, for example, changing a pointer position indicating a storage start address of the numerical data in a numerical data storage area in a random access memory (RAM) (not shown). . FIG. 4 shows an example of a numerical data storage area in the RAM, and a shift operation in byte units will be described. When one byte of data is stored in each address, two-digit decimal data is stored as shown in the figure. The pointer indicating the numerical data start address and in the first P 1, numerical data mantissa of the current stored has a .00001234567000. Left shift 2 bytes is performed by changing the pointer in P 2 in FIG mantissa of the result is exactly the same as in FIG. 2.

【0019】以上、詳細に説明したように、本発明のデ
ータパック方式を用いることにより、演算時の桁合せ処
理においてビットシフト操作に代ってバイト単位のシフ
ト操作が可能となり、しかも該シフト操作も、例えばラ
ンダムアクセスメモリ(RAM)内での数値データ記憶
開始アドレスを示すポインタ位置の変更により、ソフト
ウェアにて実現可能である。
As described in detail above, by using the data pack method of the present invention, it is possible to perform a byte-by-byte shift operation in place of a bit shift operation in digit alignment processing at the time of operation. This can also be realized by software, for example, by changing a pointer position indicating a numerical data storage start address in a random access memory (RAM).

【0020】また、本発明の実施例においては1バイト
でBCDの2桁を表わしているが、これに限らずたとえ
ば1バイトを 100進数の表現で表わすことが可能であ
る。尚、この時には仮数部の各桁を7ビットを1バイト
として表現したり、符号部を8ビットの残り1ビットに
設けること等も可能である。
In the embodiment of the present invention, one byte represents two digits of the BCD. However, the present invention is not limited to this. For example, one byte can be represented by a decimal number. At this time, each digit of the mantissa part can be represented by 7 bits as one byte, or a sign part can be provided in the remaining one bit of eight bits.

【0021】[0021]

【発明の効果】本発明によれば、桁合せ時にバイト単位
シフト操作すなわちバイトムーブを用いることが可能と
なり、演算処理の高速化、特にオフィスコンピュータ等
のBCD演算の桁合せの高速化に有効である。
According to the present invention, it is possible to use a byte-by-byte shift operation, that is, a byte move, at the time of digit alignment, which is effective for speeding up arithmetic processing, especially for speeding up digit alignment for BCD operation of an office computer or the like. is there.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明のデータパック方式の説明図である。FIG. 1 is an explanatory diagram of a data pack system according to the present invention.

【図2】本発明の一実施例を示す図である。FIG. 2 is a diagram showing one embodiment of the present invention.

【図3】本発明におけるパックデータの桁合せ処理のフ
ローチャートである。
FIG. 3 is a flowchart of a pack data digit alignment process according to the present invention.

【図4】ランダムアクセスメモリー内部の数値データ記
憶開始アドレスを示すポインタの位置変化によるバイト
シフト操作の説明図である。
FIG. 4 is an explanatory diagram of a byte shift operation based on a change in the position of a pointer indicating a numerical data storage start address in a random access memory.

【図5】(a) ,(b) は従来のデータパック方式とその実
施例の説明図である。
FIGS. 5A and 5B are explanatory diagrams of a conventional data pack system and an embodiment thereof.

【図6】従来のパックデータ桁合せ処理のフローチャー
トである。
FIG. 6 is a flowchart of a conventional pack data digit alignment process.

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 2桁のBCDコードを1バイトで表現し
た複数バイトからなる仮数と、仮数部の小数点位置の桁
を100の整数乗を基数とした指数で表わした指数部と
により数値データを構成し、 2つの数値データを演算する際に、2つの数値データに
おける指数部の差を求め、 求められた差に基づいて上
記2つの数値データのうち何れか一方の数値データにお
ける仮数部をバイト単位でシフトして桁合せを行ない、 この桁合せ後に上記2つの数値データを演算する、 ようにしたことを特徴とする数値データ演算方法。
1. A two-digit BCD code is represented by one byte.
Mantissa consisting of multiple bytes and the digit at the decimal point of the mantissa
An exponent part expressed as an exponent with an integer power of 100
Is used to construct numerical data. When calculating two numerical data, the two numerical data
The difference between the exponents, and based on the difference
Note that either one of the two numerical data
A digit mantissa part is shifted by a byte unit to perform digit alignment, and after the digit alignment, the two numerical data are calculated .
JP6089603A 1994-04-27 1994-04-27 Numerical data calculation method Expired - Lifetime JP2606580B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP6089603A JP2606580B2 (en) 1994-04-27 1994-04-27 Numerical data calculation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP6089603A JP2606580B2 (en) 1994-04-27 1994-04-27 Numerical data calculation method

Publications (2)

Publication Number Publication Date
JPH06318147A JPH06318147A (en) 1994-11-15
JP2606580B2 true JP2606580B2 (en) 1997-05-07

Family

ID=13975344

Family Applications (1)

Application Number Title Priority Date Filing Date
JP6089603A Expired - Lifetime JP2606580B2 (en) 1994-04-27 1994-04-27 Numerical data calculation method

Country Status (1)

Country Link
JP (1) JP2606580B2 (en)

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62147898A (en) * 1985-12-23 1987-07-01 Matsushita Electric Works Ltd Reception signal processing circuit

Also Published As

Publication number Publication date
JPH06318147A (en) 1994-11-15

Similar Documents

Publication Publication Date Title
JPS5932817B2 (en) Device for performing binary-modulo M conversion of binary numbers
JPS6132437Y2 (en)
US4374427A (en) Divisor transform type high-speed electronic division system
JP2502836B2 (en) Preprocessing device for division circuit
US7860910B2 (en) System and method for mapping mathematical finite floating-point numbers
JP2606580B2 (en) Numerical data calculation method
US5289399A (en) Multiplier for processing multi-valued data
JPH049340B2 (en)
GB2376773A (en) Display and/or precision operations of numerical values in binary systems
US4118786A (en) Integrated binary-BCD look-ahead adder
JPS6170635A (en) Rounding controller
JP3055558B2 (en) n-bit arithmetic unit
JPH0869372A (en) Binary multiplier
US6256656B1 (en) Apparatus and method for extending computational precision of a computer system having a modular arithmetic processing unit
JPH0831024B2 (en) Arithmetic processor
US6128636A (en) Method for interfacing floating point and integer processes in a computer system
JP2624738B2 (en) Rounding method
US5751623A (en) Digital computer for adding and subtracting
JP3138342B2 (en) Variable length code decoding device
SU1363186A1 (en) Arithmetic device
JPH0381175B2 (en)
JP2723319B2 (en) How to convert a binary number to a decimal number
JP3539077B2 (en) Division method by parallel operation method
JPS6275838A (en) Arithmetic unit for numerical data with variable accuracy
SU898425A1 (en) Dividing device