JP2005031847A - Method, program, and device for integer arithmetic operation - Google Patents
Method, program, and device for integer arithmetic operation Download PDFInfo
- Publication number
- JP2005031847A JP2005031847A JP2003194381A JP2003194381A JP2005031847A JP 2005031847 A JP2005031847 A JP 2005031847A JP 2003194381 A JP2003194381 A JP 2003194381A JP 2003194381 A JP2003194381 A JP 2003194381A JP 2005031847 A JP2005031847 A JP 2005031847A
- Authority
- JP
- Japan
- Prior art keywords
- integer
- type data
- floating
- data
- floating point
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
Images
Abstract
Description
【0001】
【発明の属する技術分野】
本発明は、整数演算の方法および整数演算プログラム、ならびに整数演算装置に関し、より詳しくは整数演算装置を用いて浮動小数点型データの絶対値計算を行う技術に関する。
【0002】
【従来の技術】
コンピュータで扱う数の表現法としては、整数型や実数型などがある。整数型データでは、ビット列を固定小数点表現と解釈して、整数値を表す。実数型データ(浮動小数点型データ)では、ビット列を浮動小数点表現と解釈して、実数値を表す。浮動小数点型データの表現形式としては、例えばIEEE(Institute for Electrical and Electronics Engineering)754規格によるものがある。
【0003】
図7(A),(B)はそれぞれ、IEEE754規格による単精度および倍精度の浮動小数点型データの表現形式を表している。この表現形式では、下位ビット側(右側)から順に、仮数部F、指数部E、および符号ビットSからなるビット列で浮動小数点型データが構成される。数値表現形式で表すと、以下のとおりとなる。Bは、バイアス成分である。
(−1)S(2E−B)(1.F)
【0004】
ここでは特に、単精度の浮動小数点型データ(図7(A))について説明する。単精度の場合、31ビット目は符号を表すビットで仮数部が正の場合は0、負の場合は1となる。30〜23ビット目の8ビットは指数部を表している。指数部のビット構成は「指数値+バイアス」となる。IEEE754規格では単精度のバイアスとして127を使用している。そのため、例えば指数値が0のときは“0+127”であり、指数部は127のビット構成(0x7f)となる(“0x”は、“7f”が16進数であることを示す)。なお、指数部が0と255の場合は特別な意味があるが、ここでは説明を省略する。22〜0ビット目の23ビットは仮数部を表している。
【0005】
図8は、浮動小数点型データの絶対値演算を行うための従来の回路構成を示している。浮動小数点型データの絶対値を計算する場合、従来の手法では浮動小数点演算器103を使用した上で正の数であるか負の数であるかの判定を行う制御手段105を必要とする。従来の手法では、0より小さい値(負の数)であるか否かを判定するために1回の浮動小数点演算を行い、さらに0より小さい値であった場合には、正の数にするために再度の浮動小数点演算を行う必要がある。
【0006】
図9を参照して、この従来の絶対値演算の手法についてさらに詳しく説明する。まず、絶対値を求めたい浮動小数点型データをメモリ101からレジスタ102にロードする(ステップS101)。次に、浮動小数点演算器103による浮動小数点演算を行い、その演算結果に基づいてデータが0以上であるか否かを制御手段105が判断する(ステップS102)。
【0007】
0以上(正の数)である場合(ステップS102:Y)には、これ以上の浮動小数点演算を行う必要はなく、データをそのままレジスタ104からメモリ101へストアする(ステップS103,ステップS106)。0よりも小さい場合(ステップS102:N)には、さらに浮動小数点演算器103による浮動小数点演算を行って符号ビットを0にし(ステップS104)、その演算したデータをレジスタ104へストアする(ステップS105)。さらにそのデータをレジスタ104からメモリ101へストアする(ステップS106)。
【0008】
図9に示した絶対値演算(単精度)を実現するためのC言語による従来のプログラム例を以下に示す。
【数1】
【0009】
絶対値演算を目的としたものではないが、浮動小数点演算器を用いた浮動小数点演算に関する技術の従来例としては、例えば以下の文献記載のものがある。
【0010】
【特許文献1】
特許第2689414号公報
【特許文献2】
特許第2558669号公報
【特許文献3】
特公平07−40221号公報
【0011】
【発明が解決しようとする課題】
以上説明したように、浮動小数点型データの絶対値演算を行う場合、従来の手法では、浮動小数点演算器103を用いて最低でも1回の浮動小数点演算を行わなければならない。しかしながら、すでに良く知られているように、浮動小数点演算は演算処理が複雑であり、実行時間が長くなってしまうという問題がある。
【0012】
本発明はかかる問題点に鑑みてなされたもので、その目的は、浮動小数点型データの絶対値演算を、従来の手法に比べて高速に行うことができるようにした整数演算の方法および整数演算プログラム、ならびに整数演算装置を提供することにある。
【0013】
【課題を解決するための手段】
本発明による整数演算の方法は、符号ビットを含む浮動小数点型データの絶対値演算をコンピュータで行う整数演算の方法であって、第1の変換手段が、浮動小数点型データを符号なし整数型データに型変換するステップと、整数演算手段が、型変換された整数型データにおける、浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値に変更し、その他の部分の値は変更しないような整数演算を施すステップと、第2の変換手段が、整数演算後の整数型データを浮動小数点型データに型変換するステップとを含むものである。
【0014】
本発明による整数演算プログラムは、符号ビットを含む浮動小数点型データの絶対値演算をコンピュータに実行させるための整数演算プログラムであって、第1の変換手段が、浮動小数点型データを符号なし整数型データに型変換するステップと、整数演算手段が、型変換された整数型データにおける、浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値に変更し、その他の部分の値は変更しないような整数演算を施すステップと、第2の変換手段が、整数演算後の整数型データを浮動小数点型データに型変換するステップとを含む各ステップを、コンピュータに実行させるためのものである。
【0015】
本発明による整数演算装置は、符号ビットを含む浮動小数点型データの絶対値演算を行う整数演算装置であって、浮動小数点型データを符号なし整数型データに型変換する第1の変換手段と、型変換された整数型データにおける、浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値に変更し、その他の部分の値は変更しないような整数演算を施す整数演算手段と、整数演算後の整数型データを浮動小数点型データに型変換する第2の変換手段とを備えたものである。
【0016】
本発明による整数演算の方法および整数演算プログラム、ならびに整数演算装置では、演算対象となる浮動小数点型データが符号なし整数型データに型変換され、その整数型データにおける、浮動小数点型データの符号ビットに対応する部分が正の数を示すビット値に変更され、その他の部分の値は変更されないような整数演算が施される。そして、その整数演算後の整数型データが再度浮動小数点型データに型変換される。浮動小数点演算器を用いることなく、浮動小数点演算器よりも高速演算が可能な整数演算手段を用いることによって、高速に絶対値の計算が行われる。さらに従来の手法では、正の数であるか負の数であるかの判定を行っていたが、本発明では、そのような判定を行う必要がなく、演算サイクルの削減が可能となる。
【0017】
【発明の実施の形態】
以下、本発明の実施の形態について図面を参照して詳細に説明する。
【0018】
図1は、本発明の一実施の形態に係る整数演算の方法を実現するための具体的な装置構成例を示している。この整数演算装置は、コンピュータにより構成されるものであり、データを保持するメモリ11およびレジスタ12,14と、整数演算を行う整数演算器13と、これら各部の制御を行う制御手段15とを備えている。制御手段15は、本発明の一実施の形態に係る整数演算プログラムに従って、各部の制御を行うものである。
【0019】
この整数演算装置は、浮動小数点型データを一時的に符号なし整数型データに型変換する第1の変換手段としての機能と、型変換された整数型データに対して所定の整数演算を施す整数演算手段としての機能と、整数演算後の整数型データを再び浮動小数点型データに型変換する第2の変換手段としての機能とを有している。整数演算手段による整数演算としては、型変換された整数型データにおける、浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値(IEEE754規格では“0”)に変更するような演算を施すようになっている。この整数演算の具体例は後に詳述する。
【0020】
ここで、本実施の形態において、主に制御手段15が、本発明における「第1の変換手段」および「第2の変換手段」の一具体例に対応する。また、整数演算器13が、本発明における「整数演算手段」の一具体例に対応する。
【0021】
次に、以上のように構成された整数演算装置の動作を、本実施の形態に係る整数演算の方法と共に説明する。
【0022】
ここでは、IEEE754規格による単精度の浮動小数点型データ(図7(A))における絶対値の求め方について説明する。浮動小数点型データをビット単位で演算処理することは原則としてできない。浮動小数点型データでは、仮数部、指数部、および符号ビットという異なった要素で1つのデータが構成されているため、一義的な演算を行うことができないからである。しかし、浮動小数点型データを一旦符号なし整数型データに一時的に型変換することで、一義的なデータとして取り扱うことが可能となる。
【0023】
図4は、数値“−3.14159”を表す浮動小数点型データを符号なし整数型データに型変換した場合のデータ表現の例を示している。ここで、「型変換する」というのは、変数の取り扱うオペランドを変換するということである。従って、浮動小数点型データを整数型データに型変換するということは、ビット列自体は変えずに、そのビット列に対する解釈の仕方を浮動小数点型から整数型に変えるという意味である。符号なし整数型データに変換した場合には、形式上、仮数部、指数部、および符号ビットというビット列の区分はなくなる。
【0024】
ところで、IEEE754の浮動小数点規格では、図5に示すように仮数部、指数部、および符号ビットのすべてが0である場合、“0.0”を意味する。これに対して、図6に示すように符号ビットが1で仮数部および指数部がすべて0である場合は、“−0.0”を意味している。これによって符号ビットを0にする処理だけで絶対値を求めることが可能である。
【0025】
図2は、この整数演算装置の動作およびそれによって実現される整数演算の方法を示している。まず、制御手段15の第1の変換手段としての機能により、絶対値を求めたい浮動小数点型データを符号なし整数型データに一時的に型変換し、メモリ11からレジスタ12にロードする(ステップS11)。次に、整数演算器13の整数演算手段としての機能により、その整数型データにおける、浮動小数点型データの符号ビットに対応する部分を0にするための整数演算を行う(ステップS12)。整数演算器13は、その演算したデータをレジスタ14へストアする(ステップS13)。次に、制御手段15の第2の変換手段としての機能により、レジスタ14の整数型データを型変換して浮動小数点型データに戻し、その浮動小数点型データをメモリ11へストアする(ステップS14)。
【0026】
図3は、この整数演算の具体的な実行例を示している。図示したように、メモリ11のアドレス“0x3A71E010”に、“−3.14159”という単精度の浮動小数点型データが格納されているものとする。制御手段15は、演算プログラムによる型宣言から、アドレス“0x3A71E010”が指し示す変数の型が浮動小数点型であることを認識可能である。
【0027】
以下、図3の実行例を図2の流れ図における各ステップに対応付けて説明する。制御手段15は、アドレス“0x3A71E010”が指し示す変数の型を符号なし整数型に型変換することで、“−3.14159”という浮動小数点型データを一時的に符号なし整数型データとしてメモリ11からレジスタ12にロードする(ステップS11)。“−3.14159”は、図4に示したようなビット列で表現できる。このビット列は、16進数で“C0490FD0”と表すことができる。16進数を示す“0x”を付加すると“0xC0490FD0”と表せる。
【0028】
次に、整数演算器13によって、整数型の値“C0490FD0”における符号ビットに対応する部分を、浮動小数点型で表したときに正の数になるように変更し、それをレジスタ14にストアする(ステップS12,S13)。具体的には、符号ビットに対応する部分を0にするために、“C0490FD0”の最上位ビットのみを0にすれば良いので、“C0490FD0”と“7FFFFFFF”とのビットごとのAND演算を行う。このAND演算を行うことで、最上位ビットのみが0となり、それ以外のビット値は元のままとなる。AND演算後の値は、16進数で“40490FD0”となり、これがレジスタ14にストアされる。
【0029】
なお、図3のステップS21のように、メモリ11上のデータを浮動小数点型のままレジスタ12にロードした場合には、浮動小数点型のデータ“−3.14159”と整数型のデータ“7FFFFFFF”とのAND演算を行うことになるが、このような異なる型同士の演算はできないので、上述のように、“−3.14159”を整数型のデータ“C0490FD0”に変換する必要がある。
【0030】
最後に、制御手段15は、レジスタ14に格納された整数型データ“40490FD0”を浮動小数点型に再変換し、その浮動小数点型データをメモリ11へストアする(ステップS14)。浮動小数点型としてメモリ11へストアするため、この時点では16進数表現はできない。メモリ11へストアされた値は、符号ビットのみが変更されているため“3.14159”と正の値として表現される。
【0031】
以上の整数演算を実現するC言語による計算プログラムの具体例を以下に示す。データは、単精度とする。
【数2】
【0032】
また、下記のような計算プログラムでも同様の結果を得ることができる。
【数3】
【0033】
以上説明したように、本実施の形態によれば、浮動小数点型データを符号なし整数型データに型変換し、その整数型データにおける、浮動小数点型データの符号ビットに対応する部分を正の数を示すビット値に変更するような整数演算を施し、最後に再び浮動小数点型データに変換するようにしたので、浮動小数点演算器を用いることなく、浮動小数点演算器よりも高速演算が可能な整数演算器13を用いることができ、高速に浮動小数点型データの絶対値の計算を行うことができる。従来の浮動小数点演算器を用いた手法では、正の数であるか負の数であるかの判定を行う必要があったが、本実施の形態では、そのような判定を行う必要がなく、演算サイクルの削減が可能となる。これにより、浮動小数点型データの絶対値演算を、従来の手法に比べて高速に行うことができる。
【0034】
【発明の効果】
以上説明したように、本発明の整数演算の方法および整数演算プログラム、ならびに整数演算装置によれば、浮動小数点演算器を用いることなく、浮動小数点演算器よりも高速演算が可能な整数演算手段を用いることによって絶対値の計算を行うようにしたので、浮動小数点型データの絶対値演算を、従来の手法に比べて高速に行うことができる。従来の手法では、正の数であるか負の数であるかの判定を行う必要があったが、本発明では、そのような判定を行う必要がなく、その分、演算サイクルの削減が可能となり高速な演算を行うことができる。
【図面の簡単な説明】
【図1】本発明の一実施の形態に係る整数演算装置の構成例を示すブロック図である。
【図2】本発明の一実施の形態に係る整数演算装置による整数演算の方法を示す流れ図である。
【図3】本発明の一実施の形態に係る整数演算の方法による具体的な演算例を示す説明図である。
【図4】浮動小数点型変数を符号なし整数型変数に型変換した場合のデータ表現の例を示す説明図である。
【図5】仮数部、指数部、および符号ビットのすべてが0である場合のデータ表現を示す説明図である。
【図6】符号ビットのみが1である場合のデータ表現を示す説明図である。
【図7】浮動小数点の表現方法の一例を示す説明図である。
【図8】浮動小数点型データの絶対値演算を行うための従来の回路構成を示すブロック図である。
【図9】浮動小数点型データの絶対値演算の従来手法を示す流れ図である。
【符号の説明】
11…メモリ、12,14…レジスタ、13…整数演算器、15…制御手段。[0001]
BACKGROUND OF THE INVENTION
The present invention relates to an integer arithmetic method, an integer arithmetic program, and an integer arithmetic device, and more particularly to a technique for calculating an absolute value of floating-point data using an integer arithmetic device.
[0002]
[Prior art]
There are an integer type and a real number type as a representation method of the number handled by the computer. In integer type data, a bit string is interpreted as a fixed-point expression to represent an integer value. In real type data (floating point type data), a bit string is interpreted as a floating point representation to represent a real value. As an expression format of the floating-point type data, for example, there is a format according to IEEE (Institute for Electrical and Electronics Engineering) 754 standard.
[0003]
FIGS. 7A and 7B show the representation formats of single-precision and double-precision floating-point data according to the IEEE754 standard, respectively. In this representation format, floating-point type data is composed of a bit string composed of a mantissa part F, an exponent part E, and a sign bit S in order from the lower bit side (right side). When expressed in a numerical expression format, it is as follows. B is a bias component.
(-1) S (2 E- B) (1.F)
[0004]
Here, in particular, single-precision floating-point data (FIG. 7A) will be described. In the case of single precision, the 31st bit is a bit representing a sign, which is 0 when the mantissa is positive and 1 when negative. The 8th bit of the 30th to 23rd bits represents the exponent part. The bit configuration of the exponent part is “exponential value + bias”. The IEEE 754 standard uses 127 as a single precision bias. Therefore, for example, when the exponent value is 0, it is “0 + 127”, and the exponent part has a bit configuration of 127 (0x7f) (“0x” indicates that “7f” is a hexadecimal number). In addition, when the exponent part is 0 and 255, there is a special meaning, but the explanation is omitted here. The 23 bits of the 22nd to 0th bits represent the mantissa part.
[0005]
FIG. 8 shows a conventional circuit configuration for performing an absolute value calculation of floating point type data. When calculating the absolute value of the floating-point type data, the conventional method requires the control means 105 for determining whether the number is a positive number or a negative number after using the floating-point
[0006]
With reference to FIG. 9, this conventional absolute value calculation method will be described in more detail. First, floating point type data whose absolute value is to be obtained is loaded from the
[0007]
When it is 0 or more (a positive number) (step S102: Y), it is not necessary to perform any more floating point arithmetic, and the data is stored as it is from the register 104 into the memory 101 (steps S103 and S106). If the value is smaller than 0 (step S102: N), the floating point
[0008]
A conventional program example in C language for realizing the absolute value calculation (single precision) shown in FIG. 9 is shown below.
[Expression 1]
[0009]
Although not intended for absolute value calculation, examples of conventional techniques related to floating point calculation using a floating point calculator include those described in the following documents, for example.
[0010]
[Patent Document 1]
Japanese Patent No. 2689414 [Patent Document 2]
Japanese Patent No. 2558669 [Patent Document 3]
Japanese Patent Publication No. 07-40221 gazette
[Problems to be solved by the invention]
As described above, when performing an absolute value calculation of floating point type data, in the conventional method, the floating point
[0012]
The present invention has been made in view of such problems, and an object of the present invention is to provide an integer operation method and an integer operation which can perform an absolute value operation of floating point type data at a higher speed than a conventional method. To provide a program and an integer arithmetic unit.
[0013]
[Means for Solving the Problems]
An integer operation method according to the present invention is an integer operation method in which an absolute value operation of floating point type data including a sign bit is performed by a computer, wherein the first conversion means converts the floating point type data into unsigned integer type data. And the integer arithmetic means changes the part corresponding to the sign bit of the floating-point type data in the type-converted integer type data to a bit value indicating a positive number, and the value of the other part Includes a step of performing an integer operation that does not change, and a second conversion means performing a type conversion of the integer type data after the integer operation to floating point type data.
[0014]
An integer operation program according to the present invention is an integer operation program for causing a computer to execute an absolute value operation of floating point type data including a sign bit, wherein the first conversion means converts the floating point type data into an unsigned integer type. The step of performing type conversion to data, and the integer arithmetic means change the part corresponding to the sign bit of the floating-point type data in the type-converted integer type data to a bit value indicating a positive number, and the other part For causing a computer to execute each step including an integer operation that does not change a value, and a step in which a second conversion means performs type conversion of integer type data after integer operation to floating point type data. Is.
[0015]
An integer arithmetic device according to the present invention is an integer arithmetic device that performs an absolute value operation of floating point type data including a sign bit, and includes first conversion means for converting floating point type data into unsigned integer type data, Integer arithmetic means for performing integer arithmetic such that the part corresponding to the sign bit of floating-point type data in the integer type data subjected to type conversion is changed to a bit value indicating a positive number and the value of the other part is not changed. And second conversion means for converting the integer type data after the integer calculation into floating point type data.
[0016]
In the integer arithmetic method, integer arithmetic program, and integer arithmetic device according to the present invention, floating-point type data to be operated is type-converted to unsigned integer type data, and the sign bit of the floating-point type data in the integer type data An integer operation is performed such that the portion corresponding to the bit value is changed to a bit value indicating a positive number, and the values of the other portions are not changed. Then, the integer type data after the integer operation is converted again into floating point type data. The absolute value can be calculated at high speed by using integer arithmetic means capable of performing higher-speed arithmetic than the floating-point arithmetic unit without using the floating-point arithmetic unit. Furthermore, in the conventional method, whether the number is a positive number or a negative number is determined. However, in the present invention, it is not necessary to perform such a determination, and the calculation cycle can be reduced.
[0017]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0018]
FIG. 1 shows a specific apparatus configuration example for realizing an integer arithmetic method according to an embodiment of the present invention. This integer arithmetic unit is configured by a computer, and includes a
[0019]
This integer arithmetic unit has a function as first conversion means for temporarily converting floating-point type data to unsigned integer type data, and an integer that performs a predetermined integer operation on the type-converted integer type data It has a function as a calculation means and a function as a second conversion means for converting the integer type data after the integer calculation into floating point type data again. As an integer operation by the integer operation means, the portion corresponding to the sign bit of the floating-point data in the type-converted integer data is changed to a bit value indicating a positive number (“0” in the IEEE754 standard). It is designed to perform various operations. A specific example of this integer operation will be described later.
[0020]
Here, in the present embodiment, the control means 15 mainly corresponds to a specific example of “first conversion means” and “second conversion means” in the present invention. The
[0021]
Next, the operation of the integer arithmetic apparatus configured as described above will be described together with the integer arithmetic method according to the present embodiment.
[0022]
Here, a description will be given of how to obtain an absolute value in single precision floating point type data (FIG. 7A) according to the IEEE754 standard. In principle, floating point data cannot be processed in bit units. This is because in floating-point data, one piece of data is composed of different elements such as a mantissa part, an exponent part, and a sign bit, so that unambiguous operations cannot be performed. However, once floating-point data is temporarily converted into unsigned integer data, it can be handled as unique data.
[0023]
FIG. 4 shows an example of data representation when the floating point type data representing the numerical value “−3.14159” is type-converted to unsigned integer type data. Here, “type conversion” means that an operand handled by a variable is converted. Therefore, the type conversion of floating point type data to integer type data means that the interpretation of the bit string is changed from the floating point type to the integer type without changing the bit string itself. When converted to unsigned integer type data, there is no division of the bit string of the mantissa part, the exponent part, and the sign bit in terms of form.
[0024]
By the way, in the floating point standard of IEEE754, when all of the mantissa part, the exponent part, and the sign bit are 0 as shown in FIG. 5, it means “0.0”. On the other hand, as shown in FIG. 6, when the sign bit is 1 and the mantissa part and the exponent part are all 0, it means “−0.0”. As a result, the absolute value can be obtained only by the process of setting the sign bit to 0.
[0025]
FIG. 2 shows the operation of the integer arithmetic apparatus and the integer arithmetic method realized thereby. First, the floating point type data whose absolute value is to be obtained is temporarily converted into unsigned integer type data and loaded from the
[0026]
FIG. 3 shows a specific execution example of this integer operation. As shown in the figure, it is assumed that single precision floating point type data “−3.14159” is stored in the address “0x3A71E010” of the
[0027]
Hereinafter, the execution example of FIG. 3 will be described in association with each step in the flowchart of FIG. The control means 15 converts the type of the variable indicated by the address “0x3A71E010” into an unsigned integer type, thereby temporarily converting the floating-point type data “−3.14159” from the
[0028]
Next, the
[0029]
When the data on the
[0030]
Finally, the control means 15 reconverts the integer type data “40490FD0” stored in the
[0031]
A specific example of a calculation program in C language that realizes the above integer arithmetic is shown below. The data is single precision.
[Expression 2]
[0032]
The same result can be obtained by the following calculation program.
[Equation 3]
[0033]
As described above, according to the present embodiment, floating-point data is type-converted to unsigned integer data, and the portion corresponding to the sign bit of the floating-point data in the integer data is a positive number. An integer operation is performed to change the bit value to indicate that it is converted to floating-point type data at the end. Therefore, an integer that can be operated faster than a floating-point arithmetic unit without using a floating-point arithmetic unit The
[0034]
【The invention's effect】
As described above, according to the integer arithmetic method, integer arithmetic program, and integer arithmetic device of the present invention, the integer arithmetic means capable of performing high-speed arithmetic than the floating point arithmetic unit without using the floating point arithmetic unit is provided. Since the absolute value is calculated by using it, the absolute value calculation of the floating-point type data can be performed at a higher speed than the conventional method. In the conventional method, it is necessary to determine whether the number is a positive number or a negative number. However, in the present invention, it is not necessary to perform such a determination, and the calculation cycle can be reduced accordingly. And high-speed computation can be performed.
[Brief description of the drawings]
FIG. 1 is a block diagram illustrating a configuration example of an integer arithmetic device according to an embodiment of the present invention.
FIG. 2 is a flowchart showing an integer operation method by the integer operation apparatus according to the embodiment of the present invention.
FIG. 3 is an explanatory diagram showing a specific calculation example by an integer calculation method according to an embodiment of the present invention.
FIG. 4 is an explanatory diagram showing an example of data representation when a floating-point variable is type-converted to an unsigned integer variable.
FIG. 5 is an explanatory diagram showing a data representation when all of a mantissa part, an exponent part, and a sign bit are 0.
FIG. 6 is an explanatory diagram showing data representation when only a sign bit is 1. FIG.
FIG. 7 is an explanatory diagram showing an example of a floating-point expression method.
FIG. 8 is a block diagram showing a conventional circuit configuration for performing an absolute value calculation of floating point type data.
FIG. 9 is a flowchart showing a conventional method of calculating an absolute value of floating point type data.
[Explanation of symbols]
DESCRIPTION OF
Claims (3)
第1の変換手段が、浮動小数点型データを符号なし整数型データに型変換するステップと、
整数演算手段が、前記型変換された整数型データにおける、前記浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値に変更し、その他の部分の値は変更しないような整数演算を施すステップと、
第2の変換手段が、前記整数演算後の整数型データを浮動小数点型データに型変換するステップと
を含むことを特徴とする整数演算の方法。An integer arithmetic method in which an absolute value calculation of floating point type data including a sign bit is performed by a computer,
First converting means for converting floating-point type data to unsigned integer type data;
The integer arithmetic means changes the part corresponding to the sign bit of the floating-point type data in the type-converted integer type data to a bit value indicating a positive number, and does not change the values of the other parts. Performing an integer operation;
And a second conversion means including a step of converting the integer type data after the integer calculation into floating point type data.
第1の変換手段が、浮動小数点型データを符号なし整数型データに型変換するステップと、
整数演算手段が、前記型変換された整数型データにおける、前記浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値に変更し、その他の部分の値は変更しないような整数演算を施すステップと、
第2の変換手段が、前記整数演算後の整数型データを浮動小数点型データに型変換するステップと
を含む各ステップをコンピュータに実行させるためのものである
ことを特徴とする整数演算プログラム。An integer arithmetic program for causing a computer to execute an absolute value calculation of floating point type data including a sign bit,
First converting means for converting floating-point type data to unsigned integer type data;
The integer arithmetic means changes the part corresponding to the sign bit of the floating-point type data in the type-converted integer type data to a bit value indicating a positive number, and does not change the values of the other parts. Performing an integer operation;
An integer arithmetic program characterized in that the second conversion means causes a computer to execute each step including the step of converting the integer type data after the integer operation into floating point type data.
浮動小数点型データを符号なし整数型データに型変換する第1の変換手段と、
前記型変換された整数型データにおける、前記浮動小数点型データの符号ビットに対応する部分を、正の数を示すビット値に変更し、その他の部分の値は変更しないような整数演算を施す整数演算手段と、
前記整数演算後の整数型データを浮動小数点型データに型変換する第2の変換手段と
を備えたことを特徴とする整数演算装置。An integer arithmetic unit that performs an absolute value calculation of floating point type data including a sign bit,
First conversion means for converting floating-point data to unsigned integer data;
An integer that performs an integer operation such that the part corresponding to the sign bit of the floating-point data in the type-converted integer data is changed to a bit value indicating a positive number, and the value of the other part is not changed. Computing means;
An integer arithmetic apparatus comprising: second conversion means for converting the integer type data after the integer calculation into floating point type data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003194381A JP2005031847A (en) | 2003-07-09 | 2003-07-09 | Method, program, and device for integer arithmetic operation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003194381A JP2005031847A (en) | 2003-07-09 | 2003-07-09 | Method, program, and device for integer arithmetic operation |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2005031847A true JP2005031847A (en) | 2005-02-03 |
Family
ID=34205566
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003194381A Withdrawn JP2005031847A (en) | 2003-07-09 | 2003-07-09 | Method, program, and device for integer arithmetic operation |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2005031847A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010160708A (en) * | 2009-01-09 | 2010-07-22 | Sony Corp | Arithmetic unit, processor, compile processor and compile processing method |
-
2003
- 2003-07-09 JP JP2003194381A patent/JP2005031847A/en not_active Withdrawn
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010160708A (en) * | 2009-01-09 | 2010-07-22 | Sony Corp | Arithmetic unit, processor, compile processor and compile processing method |
US9223543B2 (en) | 2009-01-09 | 2015-12-29 | Sony Corporation | Arithmetic unit, processor, compiler and compiling method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6487097B2 (en) | Perform rounding according to instructions | |
KR102447636B1 (en) | Apparatus and method for performing arithmetic operations for accumulating floating point numbers | |
US7236995B2 (en) | Data processing apparatus and method for converting a number between fixed-point and floating-point representations | |
US8402078B2 (en) | Method, system and computer program product for determining required precision in fixed-point divide operations | |
US9608662B2 (en) | Apparatus and method for converting floating-point operand into a value having a different format | |
JPH10207693A (en) | Floating point arithmetic unit | |
JP3178746B2 (en) | Format converter for floating point numbers | |
US6233595B1 (en) | Fast multiplication of floating point values and integer powers of two | |
Tsen et al. | A combined decimal and binary floating-point multiplier | |
US7080112B2 (en) | Method and apparatus for computing an approximation to the reciprocal of a floating point number in IEEE format | |
GB2549153A (en) | Apparatus and method for supporting a conversion instruction | |
JP2018097864A (en) | Leading zero anticipation | |
JP2005031847A (en) | Method, program, and device for integer arithmetic operation | |
JP2018524706A (en) | Apparatus and method for processing floating point values | |
JP2517064B2 (en) | Denormalized number processing method | |
JP2645422B2 (en) | Floating point processor | |
KR101922462B1 (en) | A data processing apparatus and method for performing a shift function on a binary number | |
JP4428778B2 (en) | Arithmetic device, arithmetic method, and computing device | |
JP3295949B2 (en) | Floating-point operation method and device | |
JP2005115410A (en) | Operation unit | |
JP2006243826A (en) | Floating point arithmetic device and computer program for operating m-root of floating-point value | |
JP2005031848A (en) | Method, program, and device for floating point arithmetic operation | |
EP1820092A2 (en) | Electronic device having multi operand arithmetic circuitry | |
JPH02165225A (en) | Arithmetic processing unit for floating point numeral with accuracy | |
JPH05100826A (en) | Reciprocal arithmetic unit |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20060509 |
|
A761 | Written withdrawal of application |
Free format text: JAPANESE INTERMEDIATE CODE: A761 Effective date: 20080226 |