[go: up one dir, main page]

CN1261860C - Exponential calculation method and device for floating point numbers - Google Patents

Exponential calculation method and device for floating point numbers Download PDF

Info

Publication number
CN1261860C
CN1261860C CN 02127091 CN02127091A CN1261860C CN 1261860 C CN1261860 C CN 1261860C CN 02127091 CN02127091 CN 02127091 CN 02127091 A CN02127091 A CN 02127091A CN 1261860 C CN1261860 C CN 1261860C
Authority
CN
China
Prior art keywords
floating
mentioned
exponent
point number
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 - Fee Related
Application number
CN 02127091
Other languages
Chinese (zh)
Other versions
CN1472635A (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.)
Silicon Integrated Systems Corp
Original Assignee
Silicon Integrated Systems 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 Silicon Integrated Systems Corp filed Critical Silicon Integrated Systems Corp
Priority to CN 02127091 priority Critical patent/CN1261860C/en
Publication of CN1472635A publication Critical patent/CN1472635A/en
Application granted granted Critical
Publication of CN1261860C publication Critical patent/CN1261860C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Complex Calculations (AREA)

Abstract

An exponent operation device for floating-point numbers, which is used to obtain an exponent operation result with a floating-point number base 2, comprising: a conversion device for receiving floating point number input, converting the floating point number into an integer part and a fractional part output; k index lookup tables, the fractional part has N bits, the N bits are divided into K parts, each part has N bits1、N2、…、NKBit, and N ═ N1+N2+…+NKEach index table receives an input of the N parts and generates an output result by table look-up; and a multiplier, for receiving the output result input of each exponent comparison table and generating a mantissa; the integer part is an exponent, an exponent operation result is represented by mantissa, exponent and output sign number with a value of zero, and the expression method of the exponent operation result is as follows: (-1)Sy·2Ey·myWhere Sy is the number of symbols, Ey is the exponent, myIs a mantissa, 1 is less than or equal to my< 2, and N, N as described above1、N2、…、NKIs a natural number.

Description

浮点数的指数运算方法和装置Exponential calculation method and device for floating point numbers

技术领域technical field

本发明是有关于一种指数运算的方法和装置,特别是有关一种浮点数的指数运算方法和装置。The present invention relates to a method and device for exponential calculation, in particular to a method and device for exponential calculation of floating point numbers.

背景技术Background technique

在目前的电子计算机中,浮点数F最常用的表示法为:In the current electronic computer, the most commonly used representation of the floating point number F is:

F=M×βE F=M× βE

其中M为尾数(mantissa),E为指数,β为指数的基数。Where M is the mantissa, E is the exponent, and β is the base of the exponent.

电机和电子工程师协会(Institute of Electrical and ElectronicEngineers,IEEE)为浮点数的表示法订立了四种标准格式,前两种格式为单一精确32位元格式(single-precision 32-bit format)以及双位精确64位元格式(double-precision 64-bit format),另外两种为延伸格式用于表示运算时的中间结果。对于单一精确32位元格式表示法而言,最重要的目的即是表现浮点数的精确度,而只有在为了得到更多的有效位数时,才利用双位精确64位元格式表示法使用双倍长度(Double Length)储存空间存放该浮点数。The Institute of Electrical and Electronic Engineers (Institute of Electrical and Electronic Engineers, IEEE) has established four standard formats for the representation of floating-point numbers. The first two formats are single-precision 32-bit format and double-bit format. Accurate 64-bit format (double-precision 64-bit format), and the other two are extended formats used to represent intermediate results during operations. For the single-precision 32-bit format representation, the most important purpose is to express the accuracy of floating-point numbers, and only use the double-bit precise 64-bit format representation to obtain more effective digits. The double length (Double Length) storage space stores the floating point number.

参阅图1,图1显示上述单一精确32位元格式表示法的示意图。在此表示法中,以2为基数,浮点数F=(-1)S·2E·M,其中M为该浮点数的尾数(mantissa),使用23位元表示,E为该浮点数的指数,使用8位元表示,S为该符点数的符号数使用1位元表示。Referring to FIG. 1, FIG. 1 shows a schematic diagram of the above-mentioned single precise 32-bit format representation. In this notation, with 2 as the base, the floating point number F=(-1) S 2 E ·M, where M is the mantissa of the floating point number, represented by 23 bits, and E is the mantissa of the floating point number The exponent is represented by 8 bits, and S is the symbol number of the point number represented by 1 bit.

在目前的电子计算机中,所有的运算几乎都采用浮点数的运算,因此浮点数的运算效率决定了该电子计算机的效能。而在目前的做法中,通常都使用查表的方法,事先建立一对照表,在运算时配合查表,以求得浮点数的指数运算结果,而用此方法做浮点数的指数运算时,会碰到一些运算精确度的问题,一个8位元的对照表已是相当庞大的,但使用8位元的对照表做浮点数的指数运算,其运算结果的精确度仍是不够的,因为通常一个浮点数尾数的部分都有23位元。In current electronic computers, almost all calculations use floating-point calculations, so the calculation efficiency of floating-point numbers determines the performance of the electronic computer. In the current practice, the method of looking up the table is usually used to establish a comparison table in advance, and cooperate with the table lookup during the operation to obtain the result of the exponential operation of the floating-point number. When using this method to perform the exponential operation of the floating-point number, There will be some problems with the accuracy of calculations. An 8-bit comparison table is already quite large, but using an 8-bit comparison table to perform floating-point exponent operations, the accuracy of the operation results is still not enough, because Usually the mantissa part of a floating point number has 23 bits.

发明内容Contents of the invention

有鉴于此,本发明的主要目的在于提供一种浮点数的指数运算装置和方法,用于获得具有最高精确度的浮点数的指数运算结果。In view of this, the main purpose of the present invention is to provide a floating-point number exponent operation device and method for obtaining the floating-point number exponent operation result with the highest precision.

为达成上述目的,本发明提供一种浮点数的指数运算装置,用于获得一浮点数以2为底的一指数运算结果,该浮点数的表示法为(-1)Sx·2Ex·mx,该指数运算结果的表示法为(-1)Sy·2Ey·my,其中Sx为该浮点数的符号数、Sy为该指数运算结果的符号数、Ex为该浮点数的指数、Ey为该指数运算结果的指数、mx为该浮点数的尾数、my为该指数运算结果的尾数且1≤mx<2、1≤my<2,该指数运算装置包括:一转换装置,用以接收上述浮点数的符号数、上述浮点数的指数以及上述浮点数的尾数输入,将上述浮点数转换成一整数部分和一分数部分输出;K个指数对照表,上述分数部分具有N个位元,将N个位元分成K份,每一部分分别具有N1、N2、...、NK位元,且N=N1+N2+...+NK,每一个指数表接收上述K部分中的一份输入,并且查表产生一输出结果;一乘法器,用以接收上述每一个指数对照表的输出结果输入,并且产生上述指数运算结果的尾数。其中上述转换装置输出的整数部分为上述指数运算结果的指数,上述指数运算结果的符号数其值为零,且上述N、N1、N2、...、NK为自然数。In order to achieve the above object, the present invention provides a floating-point number exponent operation device, which is used to obtain a floating-point number with base 2 as an exponent operation result, and the representation of the floating-point number is (-1) Sx 2 Ex m x , the expression of the exponent operation result is (-1) Sy 2 Ey m y , where Sx is the symbol number of the floating point number, Sy is the symbol number of the exponent operation result, Ex is the exponent of the floating point number, Ey is the exponent of the exponent operation result, m x is the mantissa of the floating point number, m y is the mantissa of the exponent operation result and 1≤m x <2, 1≤m y <2, and the exponent operation device includes: a conversion The device is used to receive the sign number of the floating point number, the exponent of the floating point number and the mantissa input of the floating point number, and convert the floating point number into an integer part and a fractional part for output; K exponent comparison tables, the fractional part has N Divide N bits into K parts, each part has N 1 , N 2 ,..., N K bits respectively, and N=N 1 +N 2 +...+N K , each The exponent table receives an input from the above-mentioned K part, and looks up the table to generate an output result; a multiplier is used to receive the input of the output result of each of the above-mentioned exponent comparison tables, and generate the mantissa of the above-mentioned exponent operation result. Wherein the integer part output by the conversion device is the exponent of the result of the exponential operation, the value of the sign number of the result of the exponential operation is zero, and the above N, N 1 , N 2 , . . . , N K are natural numbers.

另一方面,本发明也提供一种浮点数的指数运算方法,用于获得一浮点数以2为底的一指数运算结果,该浮点数的表示法为(-1)Sx·2Ex·mx,其中Sx为该浮点数的符号数、Ex为该浮点数的指数、mx为该浮点数的尾数,且1≤mx<2,该指数运算方法包括下列步骤:首先,将上述浮点数的符号数、上述浮点数的指数以及上述浮点数的尾数输入一转换装置中;接着,在上述转换装置中把上述浮点数转换成一整数部分和一分数部分;将上述分数部分分成K个部分,上述分数部分具有N个位元,每一部分分别具有N1、N2、...、NK位元,且N=N1+N2+...+NK,每一个指数表接收上述K部分中的一份输入,并且查表产生一输出结果;接着,将上述每一个指数表的输出结果输入一乘法器中产生一尾数;最后利用上述尾数、上述整数部分,以及一值为零的符号数表示上述指数运算结果,该指数运算结果的表示法为(-1)Sy·2Ey·my,其中sy为该符号数、Ey为上述整数部分、my为上述输出尾数,且1≤my<2,且上述N、N1、N2、...、NK为自然数。On the other hand, the present invention also provides a floating-point number exponent operation method, which is used to obtain an exponent operation result of a floating-point number with base 2, and the representation of the floating-point number is (-1) Sx 2 Ex m x , where Sx is the symbol number of the floating point number, Ex is the exponent of the floating point number, m x is the mantissa of the floating point number, and 1≤m x <2, the exponent calculation method includes the following steps: first, the above floating point The sign number of point number, the exponent of above-mentioned floating-point number and the mantissa of above-mentioned floating-point number are input in a conversion device; Then, in above-mentioned conversion device, above-mentioned floating-point number is converted into an integer part and a fractional part; The above-mentioned fractional part is divided into K parts , the above-mentioned fraction part has N bits, each part has N 1 , N 2 ,..., N K bits respectively, and N=N 1 +N 2 +...+N K , each index table receives An input in the above-mentioned K part, and a look-up table produces an output result; Then, the output result of each of the above-mentioned index tables is input in a multiplier to generate a mantissa; finally use the above-mentioned mantissa, the above-mentioned integer part, and a value of The sign number of zero represents the above-mentioned exponent operation result, and the representation of the exponent operation result is (-1) Sy 2 Ey m y , wherein sy is the sign number, Ey is the above-mentioned integer part, and m y is the above-mentioned output mantissa, And 1≤my <2, and the above-mentioned N, N 1 , N 2 , ..., N K are natural numbers.

附图说明Description of drawings

图1表示习知单一精确32位元格式表示法的示意图;FIG. 1 shows a schematic diagram of a conventional single precise 32-bit format representation;

图2表示本发明浮点数的指数运算装置的架构示意图;Fig. 2 shows the schematic diagram of the structure of the exponent operation device of the floating-point number of the present invention;

图3表示本发明转换装置的架构示意图;Fig. 3 shows the schematic diagram of the structure of the conversion device of the present invention;

图4表示本发明实施例的浮点数的指数运算装置的架构示意图。FIG. 4 shows a schematic diagram of the structure of the floating-point number exponent operation device according to the embodiment of the present invention.

图号说明:Description of figure number:

M、mx-浮点数的尾数;M, m x - the mantissa of the floating-point number;

E、Ex-浮点数的指数;E, Ex-exponent of floating point number;

S、Sx-符点数的符号数;S, Sx-the symbol number of symbol points;

Ix-整数部分;Ix - integer part;

Fx-分数部分;Fx - fraction part;

10-转换装置;10 - conversion device;

12-移位装置;12 - displacement device;

14-检测装置;14 - detection device;

16-决定装置;16 - decision means;

201-20K-指数对照表;20 1 -20 K - index comparison table;

30-乘法器;30 - multiplier;

Fsc-移位分数部分;Fsc - fractional part of the shift;

Isc-移位整数部分输出;Isc - shifted integer part output;

Err-错误讯息;Err - error message;

Sy-指数运算结果的符号数;Sy - sign number of exponential operation result;

Ey-该数运算结果的指数;Ey - the exponent of the result of the number operation;

my-指数运算结果的尾数。m y - the mantissa of the result of the exponent operation.

具体实施方式Detailed ways

图2表示本发明浮点数的指数运算装置的架构示意图。如图所示,浮点数的指数运算装置包括转换装置10、K个指数对照表201-20K以及乘法器30。转换装置10用以接收一浮点数X的符号数Sx、该浮点数X的指数Ex以及该浮点数X的尾数mx输入,将该浮点数转换成一整数部分Ix和一分数部分Fx输出并且在无法将该浮点数表示成整数部分和分数部分时输出错误讯息Err。分数部分Fx具有N个位元,将N个位元分成K份,每一部分分别具有N1、N2、...、NK位元,且N=N1+N2+...+NK,K个指数对照表201-20K中的每一个指数表接收上述K部分中的一份输入,并且查表产生一输出结果。乘法器30用以接收每一个指数表的输出结果输入,并且产生一指数运算结果Y的尾数my。其中转换装置10输出的整数部分Ix为该指数运算结果Y的指数Ey而且因为指数运算结果Y都为正数,所以指数运算结果Y的符号数Sy为零。FIG. 2 shows a schematic diagram of the structure of the floating-point exponential computing device of the present invention. As shown in the figure, the floating-point exponent calculation device includes a conversion device 10 , K exponent comparison tables 20 1 -20 K and a multiplier 30 . The conversion device 10 is used to receive the sign number Sx of a floating-point number X, the exponent Ex of the floating-point number X, and the mantissa mx of the floating-point number X as input, convert the floating-point number into an integer part Ix and a fractional part Fx output and in Error message Err is output when the floating-point number cannot be represented as an integer part and a fractional part. The fractional part Fx has N bits, and the N bits are divided into K parts, each part has N 1 , N 2 ,..., N K bits respectively, and N=N 1 +N 2 +...+ N K , each index table in the K index comparison tables 20 1 -20 K receives an input from the above K part, and looks up the table to generate an output result. The multiplier 30 is used for receiving the output result of each exponent table and generating a mantissa m y of an exponent operation result Y. The integer part Ix outputted by the conversion device 10 is the exponent Ey of the exponent operation result Y and since the exponent operation results Y are all positive numbers, the sign number Sy of the exponent operation result Y is zero.

上述浮点数X的表示法为:The representation of the above floating-point number X is:

X=(-1)Sx·2Ex·mx                    (1)X=(-1) Sx 2 Ex m x (1)

其中Sx为该浮点数的符号数,当浮点数X为正数时,浮点数的符号数Sx为0。当浮点数X为负数时,浮点数的符号数Sx为1;Ex为该浮点数的指数;mx为该浮点数的尾数,且1≤mx<2。Wherein Sx is the sign number of the floating point number, when the floating point number X is a positive number, the sign number Sx of the floating point number is 0. When the floating-point number X is a negative number, the sign number Sx of the floating-point number is 1; Ex is the exponent of the floating-point number; m x is the mantissa of the floating-point number, and 1≤m x <2.

本发明的浮点数的指数运算装置,用于获得该浮点数X以2为底的指数运算结果Y:The floating-point number exponent operation device of the present invention is used to obtain the exponent operation result Y of the floating-point number X with base 2:

Y=2X=(-1)Sy·2Ey·my                  (2)Y=2 X =(-1) Sy 2 Ey m y (2)

其中Sy为该指数运算结果的符号数,因为指数运算结果Y都为正数,所以指数运算结果Y的符号数Sy为零;Ey为该指数运算结果的指数;my为该指数运算结果的尾数,且1≤my<2。Wherein Sy is the symbol number of the exponential operation result, because the exponential operation result Y is a positive number, so the symbol number Sy of the exponential operation result Y is zero; Ey is the exponent of the exponent operation result; m y is the index of the exponent operation result mantissa, and 1≤m y <2.

为了求得Y,本发明的方法先将X分成整数部分和分数部分:In order to obtain Y, the method of the present invention first divides X into an integer part and a fractional part:

X=(-1)Sx·2Ex·mx=Ix+Fx               (3)X=(-1) Sx 2 Ex m x =Ix+Fx (3)

其中Ix为整数部分、Fx为分数部分且0≤Fx<1。Wherein Ix is an integer part, Fx is a fractional part and 0≤Fx<1.

Fx=q·2-N=(Ai·2Ni)·2-N              (4)Fx=q·2 -N =(Ai·2 Ni )·2 -N (4)

其中q为N位元数字,Ai为Ni位元数字。Among them, q is a N-digit number, and Ai is a Ni-digit number.

YY == 22 IxIx ++ FxFx == 22 IxIx &times;&times; [[ &Pi;&Pi; ii 22 AiAi &times;&times; 22 NN ii -- NN ]] -- -- -- (( 55 ))

因此,指数运算结果的指数Ey、该指数运算结果的尾数my以及指数运算结果Y的符号数Sy分别为:Therefore, the exponent Ey of the exponent operation result, the mantissa m y of the exponent operation result, and the symbol number Sy of the exponent operation result Y are respectively:

Ey=Ix                                  (6)Ey=Ix (6)

mymy == 22 FxFx == &Pi;&Pi; ii 22 AiAi &times;&times; 22 NN ii -- NN == &Pi;&Pi; ii TiTi -- -- -- (( 77 ))

Sy=0                                   (8)Sy=0 (8)

且中 Ti = &Pi; i 2 Ai &times; 2 N i - N , 且1≤i≤K,K为指数对照表的个数,而因为0≤Fx<1,所以20≤2Fx<21,即1≤2Fx<2,因此满足1≤my<2。And in Ti = &Pi; i 2 Ai &times; 2 N i - N , And 1≤i≤K, K is the number of index comparison table, and because 0≤Fx<1, so 2 0 ≤2 Fx <2 1 , that is, 1≤2 Fx <2, so 1≤m y <2 .

利用本发明的浮点数的指数运算装置可获得该浮点数X以2为底的指数运算结果Y,首先,将浮点数X的符号数Sx、浮点数X的指数Ex以及浮点数X的尾数mx输入转换装置10中。接着,在转换装置10中把浮点数X表示成整数部分Ix和分数部分Fx(参考第3式)。接着,将上述分数部分分成K个部分,上述分数部分具有N个位元,每一部分分别具有N1、N2、...、NK位元,且N=N1+N2+...+NK,每一个指数表接收上述N部分中的一份输入,并且查表产生一输出结果,再将每一个指数表的输出结果输入乘法器30中产生指数运算结果Y的尾数my(参考第4、5以及7式)。最后,利用尾数my、整数部分Ix,以及一值为零的符号数Sy,表示指数运算结果Y,该指数运算结果Y的表示法为(-1)Sy·2Fy·my,其中Sy为符号数其值为零(参考第8式),Ey为整数部分Ix(参考第6式),my为尾数且1≤my<2。Utilize the exponent operation device of floating-point number of the present invention to obtain this floating-point number X with 2 as the exponent operation result Y, at first, the symbol number Sx of floating-point number X, the exponent Ex of floating-point number X and the mantissa m of floating-point number X x is input into the conversion device 10 . Next, the floating-point number X is expressed in the conversion device 10 as an integer part Ix and a fractional part Fx (see the third formula). Next, divide the fraction part into K parts, the fraction part has N bits, each part has N 1 , N 2 , ..., N K bits, and N=N 1 +N 2 +.. .+N K , each index table receives an input in the above-mentioned N part, and looks up the table to generate an output result, and then input the output result of each index table into the multiplier 30 to generate the mantissa m y of the exponent operation result Y (Refer to formulas 4, 5 and 7). Finally, use the mantissa m y , the integer part Ix, and a symbol number Sy with a value of zero to represent the exponent operation result Y. The representation of the exponent operation result Y is (-1) Sy · 2 Fy · m y , where Sy is a symbolic number whose value is zero (refer to formula 8), Ey is the integer part Ix (refer to formula 6), m y is the mantissa and 1≤m y <2.

图3表示本发明转换装置的架构示意图。如图所示,该转换装置10包括移位装置12、检测装置14以及决定装置16。移位装置12用以接收浮点数的指数Ex以及浮点数的尾数mx输入,依据浮点数的指数Ex将浮点数的尾数mx移位,举例来说,当浮点数的指数Ex正整数,则依据该正整数将浮点数的尾数mx向左移,例如:浮点数的指数Ex为5,则浮点数的尾数mx向左移5位元,当浮点数的指数Ex负整数,则依据该正整数将浮点数的尾数mx向右移,例如:浮点数的指数Ex为-1,则浮点数的尾数mx向右移1位元,而移位装置12产生一移位分数部分Fsc和一移位整数部分Isc输出。FIG. 3 shows a schematic diagram of the structure of the conversion device of the present invention. As shown in the figure, the converting device 10 includes a shifting device 12 , a detecting device 14 and a determining device 16 . The shifting device 12 is used to receive the input of the exponent Ex of the floating point number and the mantissa m x of the floating point number, and shift the mantissa m x of the floating point number according to the exponent Ex of the floating point number. For example, when the exponent Ex of the floating point number is a positive integer, Then move the mantissa m x of the floating point number to the left according to the positive integer. For example, if the exponent Ex of the floating point number is 5, then the mantissa m x of the floating point number is shifted to the left by 5 bits. When the exponent Ex of the floating point number is a negative integer, then The mantissa m x of the floating point number is shifted to the right according to the positive integer, for example: the exponent Ex of the floating point number is -1, then the mantissa m x of the floating point number is shifted to the right by 1 bit, and the shifting device 12 generates a shift fraction Part Fsc and a shifted integer part Isc are output.

检测装置14用以检测移位装置12,在移位装置12溢位时发出错误讯息Err。决定装置16用以接收移位整数部分Isc以及浮点数的符号数Sx输入,并且依据浮点数的符号数Sx决定移位整数部分Isc的正负号以产生整数部分Ix输出该转换装置10,当Sx为1时,Ix=-Isc,当Sx为0时,Ix=Isc。其中移位分数部分Fsc输出该转换装置10后即为分数部分Fx。The detecting device 14 is used for detecting the shifting device 12, and sends an error message Err when the shifting device 12 overflows. The decision device 16 is used to receive the input of the shifted integer part Isc and the sign number Sx of the floating point number, and determine the sign of the shifted integer part Isc according to the sign number Sx of the floating point number to generate the integer part Ix to output the conversion device 10, when When Sx is 1, Ix=-Isc, and when Sx is 0, Ix=Isc. The shifted fractional part Fsc is the fractional part Fx after being output from the conversion device 10 .

图4表示本发明实施例的浮点数的指数运算装置的架构示意图。如图所示,浮点数的指数运算装置包括移位装置12、检测装置14、决定装置16、3个指数对照表201-203以及乘法器30。本实施例的浮点数的指数运算装置用于获得该浮点数X以2为底的指数运算结果Y即=2X,该浮点数X的表示法为X=(-1)Sx·2Ex·mx,其中Sx为该浮点数的符号数,以1位元表示,当浮点数X为正数时,浮点数的符号数Sx为0,当浮点数X为负数时,浮点数的符号数Sx为1;Ex为该浮点数的指数,以8位元表示;mx为该浮点数的尾数,以24位元表示,且1≤mx<2。FIG. 4 shows a schematic diagram of the structure of the floating-point number exponent operation device according to the embodiment of the present invention. As shown in the figure, the floating-point exponent computing device includes a shifting device 12 , a detecting device 14 , a determining device 16 , three exponent comparison tables 20 1 -20 3 and a multiplier 30 . The floating-point number exponent operation device of this embodiment is used to obtain the exponent operation result Y of the floating-point number X with base 2 = 2 X , and the representation of the floating-point number X is X=(-1) Sx 2 Ex . m x , where Sx is the sign number of the floating point number, expressed in 1 bit, when the floating point number X is a positive number, the floating point number Sx is 0, when the floating point number X is a negative number, the floating point number is the sign number Sx is 1; Ex is the exponent of the floating point number, expressed in 8 bits; m x is the mantissa of the floating point number, expressed in 24 bits, and 1≤m x <2.

为了求得Y,需先将X分成用8位元表示的整数部分Ix以及用23位元表示的分数部分Fx,其中0≤Fx<1;移位装置12接收浮点数的指数Ex以及浮点数的尾数mx输入,依据浮点数的指数Ex将浮点数的尾数mx移位,举例来说,当浮点数的指数Ex正整数,则依据该正整数将浮点数的尾数mx向左移,例如:浮点数的指数Ex为5,则浮点数的尾数mx向左移5位元,当浮点数的指数Ex负整数,则依据该正整数将浮点数的尾数mx向右移,例如:浮点数的指数Ex为-1,则浮点数的尾数mx向右移1位元,而移位装置12产生一移位分数部分Fsc和一移位整数部分Isc输出。检测装置14用以检测移位装置12,在移位装置12溢位时发出错误讯息Err,该错误讯息Err包括溢位讯息和向下溢位讯息。当浮点数的指数Ex大于7时,浮点数的尾数mx向左移超过7位元,此时即发出溢位讯息。当浮点数的指数Ex小于-23时,浮点数的尾数mx向右移超过23位元,此时即发出向下溢位讯息。决定装置16用以接收移位整数部分Isc以及浮点数的符号数Sx输入,并且依据浮点数的符号数Sx决定移位整数部分Isc的正负号以产生用8位元表示的整数部分Ix输出该转换装置10,当Sx为1时,Ix=-Isc,当Sx为0时,Ix=Isc。In order to obtain Y, X needs to be divided into an integer part Ix represented by 8 bits and a fractional part Fx represented by 23 bits, wherein 0≤Fx<1; the shifting device 12 receives the exponent Ex of the floating-point number and the floating-point number The mantissa m x of the floating point number is input, and the mantissa m x of the floating point number is shifted according to the exponent Ex of the floating point number. For example, when the exponent Ex of the floating point number is a positive integer, the mantissa m x of the floating point number is shifted to the left according to the positive integer , for example: the exponent Ex of the floating point number is 5, then the mantissa m x of the floating point number is shifted to the left by 5 bits, when the exponent Ex of the floating point number is a negative integer, the mantissa m x of the floating point number is shifted to the right according to the positive integer, For example, if the exponent Ex of the floating point number is -1, then the mantissa m x of the floating point number is shifted to the right by 1 bit, and the shifting device 12 generates a shifted fractional part Fsc and a shifted integer part Isc as outputs. The detecting device 14 is used for detecting the shifting device 12, and sends an error message Err when the shifting device 12 overflows, and the error message Err includes an overflow message and an underflow message. When the exponent Ex of the floating-point number is greater than 7, the mantissa m x of the floating-point number is shifted to the left by more than 7 bits, and an overflow message is issued at this time. When the exponent Ex of the floating point number is less than -23, the mantissa m x of the floating point number is shifted to the right by more than 23 bits, and an underflow bit message is issued at this time. The determining device 16 is used to receive the input of the shifted integer part Isc and the sign number Sx of the floating point number, and determine the sign of the shifted integer part Isc according to the sign number Sx of the floating point number to generate an output of the integer part Ix represented by 8 bits In the converting device 10, when Sx is 1, Ix=-Isc, and when Sx is 0, Ix=Isc.

其中移位分数部分Fsc在输出该转换装置10后即为利用23位元表示的分数部分Fx整数部分,而整数部分Ix即为指数运算结果Y的指数Ey(参考第6式)。Wherein the shifted fractional part Fsc is the integer part of the fractional part Fx represented by 23 bits after being output from the conversion device 10, and the integer part Ix is the exponent Ey of the exponent operation result Y (refer to the sixth formula).

接着,把分数部分Fx分成3个部分,分别为8位元、8位元和7位元,依序将每一个部分输入指数对照表20、22、24中,并在每一个指数对照表中产生一输出结果,再将每一个指数表的输出结果输入乘法器30中产生指数运算结果Y的尾数myThen, the fractional part Fx is divided into 3 parts, respectively 8 bits, 8 bits and 7 bits, each part is input in the index comparison table 20, 22, 24 in order, and in each index comparison table Generate an output result, and then input the output result of each exponent table into the multiplier 30 to generate the mantissa m y of the exponent operation result Y.

根据第7式:According to formula 7:

mm ythe y == 22 FxFx == &Pi;&Pi; ii 22 AiAi &times;&times; 22 NN ii -- NN == &Pi;&Pi; ii TiTi

在此实施例中,1≤i≤3,3为指数对照表的个数,所以:In this embodiment, 1≤i≤3, 3 is the number of the index comparison table, so:

mm ythe y == &Pi;Ti&Pi;Ti == TT 11 &times;&times; TT 22 &times;&times; TT 33 == 22 AA 11 &times;&times; 22 -- 88 &times;&times; 22 AA 22 &times;&times; 22 -- 1616 &times;&times; 22 AA 33 &times;&times; 22 -- 23twenty three -- -- -- (( 99 ))

其中 T 1 = 2 A 1 &times; 2 - 8 , 且A1为分数部分Fx分成的3个部分中的第一部分,为一8位元的数字; T 2 = 2 A 2 &times; 2 - 16 , 且A2为分数部分Fx分成的3个部分中的第二部分,为一8位元的数字; T 3 = 2 A 3 &times; 2 - 23 , 且A3为分数部分Fx分成的3个部分中的最后一部分,为一7位元的数字。in T 1 = 2 A 1 &times; 2 - 8 , And A 1 is the first part of the 3 parts divided into the fractional part Fx, which is an 8-bit number; T 2 = 2 A 2 &times; 2 - 16 , And A 2 is the second part of the 3 parts divided by the fractional part Fx, which is an 8-bit number; T 3 = 2 A 3 &times; 2 - twenty three , And A 3 is the last part among the 3 parts divided by the fractional part Fx, which is a 7-bit number.

因为指数运算结果Y都为正数,所以指数运算结果Y的符号数Sy为零(参考第8式)。Since the exponential operation results Y are all positive numbers, the sign number Sy of the exponential operation result Y is zero (refer to Expression 8).

最后,利用my、Ix,以及Sy表示指数运算结果Y,其表示法为Y=(-1)Sy·2Ey·my,其中Sy为该指数运算结果的符号数、Ey为该指数运算结果的指数、my为该指数运算结果的尾数,且1≤my<2。Finally, use my y , Ix , and Sy to represent the exponent operation result Y, and its notation is Y=(-1) Sy · 2 Ey · m y , where Sy is the sign number of the exponent operation result, and Ey is the exponent operation result The exponent of the result, m y is the mantissa of the exponent operation result, and 1≤m y <2.

Claims (8)

1.一种浮点数的指数运算装置,用于获得一浮点数以2为底的一指数运算结果,该浮点数的表示法为(-1)Sx·2Ex·mx,该指数运算结果的表示法为(-1)Sy·2Ey·my,其中Sx为该浮点数的符号数、Sy为该指数运算结果的符号数、Ex为该浮点数的指数、Ey为该指数运算结果的指数、mx为该浮点数的尾数、my为该指数运算结果的尾数,且1≤mx<2、1≤my<2,该指数运算装置包括:1. An exponent operation device of a floating-point number, used to obtain an exponent operation result of a floating-point number with base 2, the representation of the floating-point number is (-1) Sx · 2 Ex · m x , the exponent operation result The notation is (-1) Sy · 2 Ey · m y , where Sx is the symbol number of the floating point number, Sy is the symbol number of the exponent operation result, Ex is the exponent of the floating point number, and Ey is the exponent operation result , m x is the mantissa of the floating-point number, m y is the mantissa of the exponent operation result, and 1≤m x <2, 1≤m y <2, the exponential operation device includes: 一移位装置,用以接收上述浮点数的指数以及上述浮点数的尾数输入,当该浮点数的指数为正整数时,将上述浮点数的尾数向左移位相当于上述浮点数的指数之位,而当该浮点数的指数为负整数时,将上述浮点数的尾数向右移位相当于上述浮点数的指数之位,以产生一移位数,并且分别输出该移位数的一分数部分和一移位整数部分;A shifting device, used to receive the input of the exponent of the floating point number and the mantissa of the above floating point number, when the exponent of the floating point number is a positive integer, shift the mantissa of the floating point number to the left by an amount equal to the exponent of the floating point number bit, and when the exponent of the floating point number is a negative integer, the mantissa of the above floating point number is shifted to the right by the bit equivalent to the exponent of the above floating point number to generate a shifted number, and one of the shifted number is output respectively a fractional part and a shifted integer part; 一决定装置,用以接收上述移位整数部分以及上述浮点数的符号数输入,并且依据上述浮点数的符号数决定上述移位整数部分的正负号,以产生带有上述正负号的上述移位整数部分为一整数部分;A determining device, used to receive the input of the above-mentioned shifted integer part and the sign number of the above-mentioned floating point number, and determine the sign of the above-mentioned shifted integer part according to the sign number of the above-mentioned floating-point number, so as to generate the above-mentioned shift integer part into an integer part; K个指数对照表,上述分数部分具有N个位元,将N个位元分成K份,每一部分分别具有N1、N2、...、NK位元,且N=N1+N2+...+NK,每一个指数对照表分别接收上述K部分中的一份对应该指数对照表的输入,并且查表产生一输出结果;以及K index comparison table, the above-mentioned fraction part has N bits, and the N bits are divided into K parts, each part has N 1 , N 2 , ..., N K bits respectively, and N=N 1 +N 2 +...+N K , each index comparison table receives an input corresponding to the index comparison table in the above K part, and looks up the table to generate an output result; and 一乘法器,用以接收上述每一个指数对照表的输出结果作为输入,并且产生上述指数运算结果的尾数;a multiplier, used to receive the output result of each of the above-mentioned index comparison tables as an input, and generate the mantissa of the above-mentioned exponent operation result; 其中上述决定装置输出的整数部分为上述指数运算结果的指数,上述指数运算结果的符号数其值为零,且上述N、N1、N2、...、NK为自然数。Wherein the integer part output by the above-mentioned determining means is the exponent of the above-mentioned exponential operation result, the sign number of the above-mentioned exponential operation result has a value of zero, and the above-mentioned N, N 1 , N 2 , . . . , N K are natural numbers. 2.根据权利要求1所述的浮点数的指数运算装置,其特征在于:更包括一检测装置,用以检测上述移位装置,在上述移位装置溢位时发出一错误信息。2. The floating-point exponent operation device according to claim 1, further comprising a detection device for detecting the shifting device, and sending an error message when the shifting device overflows. 3.根据权利要求1所述的浮点数的指数运算装置,其特征在于:上述第i个指数对照表接收上述分数部分中的第i部分Ai的输入,上述分数部分具有N位元,Ai具有Ni位元,其输出结果Ti为: Ti = 2 Ai &times; 2 Ni - N , 其中i为自然数。3. The exponential operation device of floating-point number according to claim 1, characterized in that: the above-mentioned i-th index comparison table receives the input of the i-th part Ai in the above-mentioned fractional part, and the above-mentioned fractional part has N bits, and Ai has Ni bit, the output result Ti is: Ti = 2 Ai &times; 2 Ni - N , where i is a natural number. 4.根据权利要求1所述的浮点数的指数运算装置,其特征在于:当上述浮点数为正数时,上述浮点数的符号数为0,当上述浮点数为负数时,上述浮点数的符号数为1。4. The exponential operation device of floating-point number according to claim 1, characterized in that: when the above-mentioned floating-point number is a positive number, the sign number of the above-mentioned floating-point number is 0, and when the above-mentioned floating-point number is a negative number, the sign number of the above-mentioned floating-point number is 0. The number of symbols is 1. 5.一种浮点数的指数运算方法,用于获得一浮点数以2为底的一指数运算结果,该浮点数的表示法为(-1)Sx·2Ex·mx,其中Sx为该浮点数的符号数、Ex为该浮点数的指数、mx为该浮点数的尾数,且1≤mx<2,该指数运算方法包括下列步骤:5. An exponent operation method of a floating-point number, used to obtain an exponent operation result of a floating-point number with base 2, the representation of the floating-point number is (-1) Sx 2 Ex m x , where Sx is the The symbol number of the floating-point number, Ex is the exponent of the floating-point number, m x is the mantissa of the floating-point number, and 1≤m x <2, the exponent calculation method comprises the following steps: 利用一移位装置,接收上述浮点数的指数以及上述浮点数的尾数输入,当该浮点数的指数为正整数时,将上述浮点数的尾数向左移位相当于上述浮点数的指数之位,而当该浮点数的指数为负整数时,将上述浮点数的尾数向右移位相当于上述浮点数的指数之位,以产生一移位数,并且分别输出该移位数的一分数部分和一移位整数部分;Using a shifting device to receive the input of the exponent of the floating-point number and the mantissa of the above-mentioned floating-point number, when the exponent of the floating-point number is a positive integer, shift the mantissa of the above-mentioned floating-point number to the left by a position equivalent to the exponent of the above-mentioned floating-point number , and when the exponent of the floating-point number is a negative integer, shift the mantissa of the above-mentioned floating-point number to the right by the bit equivalent to the exponent of the above-mentioned floating-point number to generate a shifted number, and output a fraction of the shifted number respectively part and a shifted integer part; 利用一决定装置,接收上述移位整数部分以及上述浮点数的符号数输入,并且依据上述浮点数的符号数决定上述移位整数部分的正负号,以产生带有上述正负号的上述移位整数部分为一整数部分;将上述分数部分分成K个部分,上述分数部分具有N个位元,每一部分分别具有N1、N2、...、NK位元,且N=N1+N2+...+NK,每一个指数对照表分别接收上述K部分中的一份对应该指数对照表的输入,并且查表产生一输出结果;Utilize a determining device to receive the input of the above-mentioned shifted integer part and the sign number of the above-mentioned floating point number, and determine the sign of the above-mentioned shifted integer part according to the sign number of the above-mentioned floating-point number, so as to generate the above-mentioned shift with the above-mentioned sign The bit integer part is an integer part; the above-mentioned fractional part is divided into K parts, the above-mentioned fractional part has N bits, and each part has N1 , N2 , ..., NK bits respectively, and N= N1 +N 2 +...+N K , each index comparison table receives an input corresponding to the index comparison table in the above K part, and looks up the table to generate an output result; 将上述每一个指数表的输出结果输入一乘法器中产生一尾数;以及inputting the output of each of the above exponent tables into a multiplier to generate a mantissa; and 利用上述尾数、上述整数部分,以及一值为零的符号数表示上述指数运算结果,该指数运算结果的表示法为(-1)Sy·2Ey·my,其中Sy为该符号数、Ey为上述整数部分、my为上述输出尾数,1≤my<2,且上述N、N1、N2、...、NK为自然数。Utilize the above-mentioned mantissa, the above-mentioned integer part, and a symbolic number with a value of zero to represent the above-mentioned exponent operation result, the representation of the exponent operation result is (-1) Sy 2 Ey m y , where Sy is the symbolic number, Ey is the above-mentioned integer part, my y is the above-mentioned output mantissa, 1≤my <2, and the above-mentioned N, N 1 , N 2 , ..., N K are natural numbers. 6.根据权利要求5所述的浮点数的指数运算方法,其特征在于:在上述转换装置中把上述浮点数表示成一整数部分和一分数部分的步骤更包括子步骤:6. The exponent calculation method of floating-point numbers according to claim 5, characterized in that: in the above-mentioned conversion device, the step of representing the above-mentioned floating-point numbers as an integer part and a fractional part further includes substeps: 利用一检测装置,在上述移位装置溢位时发出上述错误信息。Using a detection device, the above error message is issued when the above shift device overflows. 7.根据权利要求5所述的浮点数的指数运算方法,其特征在于:上述第i个指数对照表接收上述分数部分中的第i部分Ai的输入,上述分数部分具有N位元,Ai具有Ni位元,其输出结果Ti为: Ti = 2 Ai &times; 2 Ni - N , 其中i为自然数。7. The exponent operation method of floating-point numbers according to claim 5, characterized in that: the above-mentioned i-th index comparison table receives the input of the i-th part Ai in the above-mentioned fractional part, and the above-mentioned fractional part has N bits, and Ai has Ni bit, the output result Ti is: Ti = 2 Ai &times; 2 Ni - N , where i is a natural number. 8.根据权利要求5所述的浮点数的指数运算方法,其特征在于:当上述浮点数为正数时,上述浮点数的符号数为0,当上述浮点数为负数时,上述浮点数的符号数为1。8. The exponential operation method of floating-point numbers according to claim 5, characterized in that: when the above-mentioned floating-point numbers are positive numbers, the sign number of the above-mentioned floating-point numbers is 0, and when the above-mentioned floating-point numbers are negative numbers, the sign number of the above-mentioned floating-point numbers is 0. The number of symbols is 1.
CN 02127091 2002-07-29 2002-07-29 Exponential calculation method and device for floating point numbers Expired - Fee Related CN1261860C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 02127091 CN1261860C (en) 2002-07-29 2002-07-29 Exponential calculation method and device for floating point numbers

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 02127091 CN1261860C (en) 2002-07-29 2002-07-29 Exponential calculation method and device for floating point numbers

Publications (2)

Publication Number Publication Date
CN1472635A CN1472635A (en) 2004-02-04
CN1261860C true CN1261860C (en) 2006-06-28

Family

ID=34143466

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 02127091 Expired - Fee Related CN1261860C (en) 2002-07-29 2002-07-29 Exponential calculation method and device for floating point numbers

Country Status (1)

Country Link
CN (1) CN1261860C (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7321914B2 (en) * 2004-02-18 2008-01-22 General Motors Corporation Fast method for calculating powers of two as a floating point data type
EP2189897B1 (en) * 2008-11-19 2013-04-24 VEGA Grieshaber KG Multiplication of an integer with a floating-point number
CN104866281A (en) * 2014-02-21 2015-08-26 北京国睿中数科技股份有限公司 Device and method for realizing floating-point number symbol analysis and substitution
CN105183426A (en) * 2015-08-18 2015-12-23 深圳市振邦智能科技有限公司 Floating point number display method and apparatus applied to 8-bit single chip microcomputer
CN113721884B (en) * 2021-09-01 2022-04-19 北京百度网讯科技有限公司 Operation method, operation device, chip, electronic device and storage medium

Also Published As

Publication number Publication date
CN1472635A (en) 2004-02-04

Similar Documents

Publication Publication Date Title
CN105468331B (en) Independent floating point conversion unit
CN1049778C (en) Arithmetic device for realizing Viterbi decoding of convolutional code for error correction
CN105634499B (en) A Data Conversion Method Based on New Short Floating-Point Data
CN1215862A (en) Computing method and computing device
CN104598197B (en) A kind of floating-point inverse and/or inverse square root operation method and its device
CN1658153A (en) Composite Dynamic Fixed-point Number Representation and Algorithm and Its Processor Structure
CN1173930A (en) Logarithm/antilogarithmic converter using quadratic term and its usage method
CN1431594A (en) Method for parallel computing code of CRC in multiple channels and multiple bits
CN110515584A (en) Floating-point Computation method and system
CN1261860C (en) Exponential calculation method and device for floating point numbers
US20040010531A1 (en) Apparatus and method for calculating an exponential calculating result of a floating-point number
CN1265281C (en) Logarithm operation method and device for floating point numbers
JP2001005643A (en) Exponentiation unit
CN108109166A (en) For the computational methods and device of Image entropy in automatic exposure
US9059726B2 (en) Apparatus and method for performing a convert-to-integer operation
JP4273071B2 (en) Divide and square root calculator
CN101056415A (en) A method and device for converting the multiplication operation to the addition and shift operation
CN102566965B (en) Floating-point number logarithmic operation device with flat errors
CN104615404A (en) A high-speed floating-point division unit device based on table look-up operation
CN1205583C (en) Square-root computer capable of reducing error
Boldo et al. When double rounding is odd
CN1783060A (en) Cholesky decomposition algorithm device
CN116594954A (en) A general in-memory matrix computing engine and its operation method
CN100340940C (en) Logarithmic Transformation Method and Device
CN1570847A (en) Digital Signal Processor Using Jumping Floating-Point Arithmetic

Legal Events

Date Code Title Description
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20060628

Termination date: 20160729