Apparatus and method for calculating an exponential calculating result of a floating-point number
Granted 21 Jun 2005 · no office action yet
Assignee: SILICON INTEGRATED SYSTEMS CORP.
Law firm: Law firm · Log in to unlock
Attorney: Attorney · Log in to unlock
Inventors: Chung-Yen Lu, Kuo-Wei Yeh · Examiner: Chuong Dinh Ngo · AU 2124 · TC 2100
Life of the application
6 dated eventsAbstract
An apparatus for calculating an exponential calculating result for a base 2 floating-point number comprises a transforming device, K exponential tables and a multiplier. The transforming device receives the floating-point number, transforms the floating-point number to an integer part and a fractional part and outputs the integer part and the fractional part. The fractional part is an N-bit number and divided into K parts which have N 1 , N 2 , . . . , N K bits respectively, wherein N=N 1 +N 2 + . . . +N K . Each of the exponential tables receives one of the K parts divided from the fractional part and outputs a result. The multiplier receives all results from the exponential tables and outputs a mantissa. The integer part outputted form the transforming device is an exponent. The mantissa, the exponent and a sign whose value is 0 is used to represent an exponential calculating result which is represented in the following format: (−1) Sy ·2 Ey ·m y , where S y is the sign whose value is 0, E y is the integer part, m y is the mantissa and 1≦m y <2.
Description
6 parts›BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates in general to an apparatus and a method for exponential computation, and more particularly to an apparatus and method to precisely calculate an exponential calculating result for a base 2 floating-point number.
2. Description of the Related Art
The representation of floating-point numbers is similar to the commonly used scientific notation and consists of two parts, the mantissa M and the exponent. The floating-point number F represented by the pair (M,E) has the value,
›F=M×β E
Where β is the base of the exponent.
In an effort to unify methods employed in calculater systems for performing binary floating-point arithmetic, the IEEE in the early 1980's standardized calculater floating-point numbers. Such binary floating-point numbers make possible the manipulation of large as well as small numbers with great precision, and thus are often used in scientific calculations. They typically comprise either single precision format or double precision format, with single precision operating on 32-bit operands and double precision operating on 64-bit operands. Both single and double precision numbers constitute a bit-string characterized by three fields: a single sign bit, several exponent bits, and several fraction or mantissa bits, with the sign bit being the most significant bit, the exponent bits being the next most significant, and the mantissa bits being the least significant.
FIG. 1 is a diagram showing the form of the single format. Since base 2 was selected, a flowing point number F in the single format has the form:
F =(−1) S ·2 E−127 ·(1. f )
Where
S=sign bit; E=8-bit exponent biased by 127; f=F's 23-bit fraction or mantissa which, together with an implicit leading 1, yield the significant digit field “ 1.--”.
In present day calculators, the calculation of the floating-point is used for almost all kinds of calculations. Calculator efficiency depends on the efficiency of the calculation of the floating-point. For exponential computation of a floating-point number, an exponential table is usually determined in advance. Then, the result is found by looking up the table. However, when using the exponential table, there is a problem of precision. An 8-bit exponential table is quite large. A memory with large size is required to store the 8-bit exponential table. But if an 8-bit exponential table is used for exponential computation of a floating-point number, the precision of the calculating result is not sufficient. Because the mantissa part of the floating-point number has 23 bits, to precisely calculate an exponent of a floating-point number, an 8-bit exponential table is not enough.
›SUMMARY OF THE INVENTION
In view of the above, an object of the present invention is to provide an apparatus and method for calculating an exponential calculating result for a base 2 floating-point number to obtain a calculating result with full precision without the need of a large memory.
The present invention provides an apparatus for calculating an exponential calculating result for a base 2 floating-point number wherein the floating-point number is represented in the format of (−1) Sx ·2 Ex ·m x and the exponential calculating result Y is represented in the format (−1) Sy ·2 Ey ·m y , where S x is a sign of the floating-point number, S y is a sign of the exponential calculating result, E x is an exponent of the floating-point number, E y is an exponent of the exponential calculating result, m x is a mantissa of the floating-point number, m y is a mantissa of the exponential calculating result, 1≦m x <2 and 1≦m y <2, the apparatus comprising: a transforming device for receiving the sign of a floating-point number, the exponent of the floating-point number and the mantissa of the floating-point number, and transforming the floating-point number to an integer part and a fractional part and outputting them, wherein the fractional part is an N-bit number divided into K parts which have N 1 , N 2 , . . . , N K bits respectively, wherein N=N 1 +N 2 + . . . +N K ; K exponential tables, each of the exponential tables for receiving one of the K parts divided from the fractional part, and outputting a result; and a multiplier for receiving all results from the exponential tables and outputting the mantissa of the exponential calculating result; wherein the integer part output from the transforming device is the exponent of the exponential calculating result, and the sign of the exponential calculating result is 0 and N, K, N 1 , N 2 , . . . , N K are natural numbers.
Furthermore, the invention provides a method for calculating an exponential calculating result for a base 2 floating-point number wherein the floating-point number is represented in the format of (−1) Sx ·2 Ex ·m x , where S x is a sign of the floating-point number, E x is an exponent of the floating-point number, m x is a mantissa of the floating-point number, and 1≦m x <2, the method comprising the steps of: inputting the sign of the floating-point number, the exponent of the floating-point number, and the mantissa of the floating-point number to a transforming device; transforming the floating-point number to an integer part and a fractional part in the transforming device, wherein the fractional part is an N-bit number divided into K parts which have N 1 , N 2 , . . . , N K bits respectively, wherein N=N 1 +N 2 + . . . +N K ; receiving each of K parts divided from the fractional part into an exponential table and outputting a result; inputting all results from the exponential tables to a multiplier to produce a mantissa; and using the mantissa, the integer part and a sign whose value is 0 to represent the exponential calculating result, which is represented in the following format: (−1) Sy ·2 Ey ·m y , where S y is the sign whose value is 0, E y is the integer part, m y is the mantissa and 1≦m y <2.
›BRIEF DESCRIPTION OF THE DRAWINGS
The present invention can be more fully understood by reading the subsequent detailed description in conjunction with the examples and references made to the accompanying drawings, wherein:
FIG. 1 is a diagram showing the form of the single format;
FIG. 2 is a schematic diagram showing the apparatus for calculating an exponential calculating result of a floating-point number according to the present invention;
FIG. 3 is a schematic diagram showing the transforming device according to the present invention; and
FIG. 4 is a schematic diagram showing the apparatus for calculating an exponential calculating result of a floating-point number according to the embodiment of the present invention.
›DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT · 1 of 2
FIG. 2 is a schematic diagram showing the apparatus for calculating an exponential calculating result of a floating-point number according to the present invention. The apparatus 100 , as shown in FIG. 2 , comprises a transforming device 10 , a plurality of exponential tables 20 1 ˜20 K , and a multiplier 30 . The transforming device 10 receives a sign of a floating-point number (X) S x , an exponent of the floating-point number (X) E x , and a mantissa of the floating-point number (X) m x . The transforming device 10 transforms the floating-point number X to an integer part I x and a fractional part F x and outputs them. Besides, the transforming device 10 outputs an error signal Err if not successful in transforming the floating-point number X to the integer part I x and the fractional part F x . The fractional part F x is an N-bit number and is divided into K parts which have N 1 , N 2 , . . . , N K bits respectively, wherein N=N 1 +N 2 + . . . +N K . Each of the exponential tables 20 1 ˜20 K receives one of the K parts divided from the fractional part F x and outputs a result. The exponential tables 20 1 ˜20 K are predetermined exponential tables for calculating the exponential base-2. The multiplier 30 receives all results from the exponential tables 20 1 ˜20 K and outputs a mantissa of a exponential calculating result (Y) m y . Moreover, the integer part I x output from the transforming device 10 is an exponent of the exponential calculating result (Y) E y . The exponential calculating result Y is a positive number. Therefore, a sign of the exponential calculating result (Y) S y is 0.
The floating-point number X is represented in the following format:
X= (−1) Sx ·2 Ex ·m x (1)
where S x is the sign of the floating-point number X, when the floating-point number X is a positive number, the sign S x is 0, when the floating-point number X is a negative number, the sign S x is 1, E x is the exponent of the floating-point number X, m x is the mantissa of the floating-point number X and 1≦m x <2.
The present invention is used to calculate an exponential calculating result Y for the base 2 floating-point number X, the exponential calculating result Y is given by
Y= 2 X =(−1) Sy ·2 Ey ·m y (2)
where S y is the sign of the exponential calculating result Y, and hence the exponential calculating result Y is a positive number, S y is 0, E y is the exponent of the exponential calculating result Y, m y is the mantissa of a exponential calculating result Y and 1≦m y <2.
To find Y, the first step in the present invention is to divide X into integer part and a fractional part.
X =(−1) Sx ·2 Ex ·m x =I x +F x (3)
where I x is the integer part and F x is the fractional part.
F x = q · 2 - N = ( ∑ 1 A 1 · 2 N 1 ) · 2 - N ( 4 )
where q is a N-bit number, and A i is a N i -bit number.
Y = 2 I x + F x = 2 I x × [ ∏ 1 2 A 1 2 N 1 - N ] ( 5 )
That is, the sign, exponent and mantissa of Y would be:
E y =I x (6)
m y = 2 F x = ∏ 1 2 A 1 · 2 N i - N = ∏ 1 T i ( 7 )
S y =0 (8)
where T i = ∏ 1 2 A 1 · 2 N i - N ,
and 1≦i≦K, K is the number of the exponential tables, and 0≦F x <1→2 0 ≦2 F x <2 1 →1≦2 F x <2→1≦m y <2.
The present invention is used to calculate an exponential calculating result Y for the base 2 floating-point number X. First, the sign of the floating-point number S x , the exponent of the floating-point number E x , and the mantissa of the floating-point number m x are inputted to the transforming device 10 . Then, the floating-point number X is transformed to the integer part I x and the fractional part F x by the transforming device 10 (referring to the equation 3). The fractional part F x is an N-bit number and is divided into K parts which have N 1 , N 2 , . . . , N K bits respectively, wherein N=N 1 +N 2 + . . . +N K . Then, each of the exponential tables 20 1 ˜20 K receives one of the K parts divided from the fractional part F x and outputs a result. When the i-th exponential table receives the i-th part A i with N i bits of the parts divided from the fractional part with N bits, the result T i for outputting is: T i =2 A i ×2 N 1 −N , where i is a natural number. The multiplier 30 receives all results from the exponential tables 20 1 ˜20 K and outputs the mantissa my (referring to the equation 4, 5, 7). Finally, the exponential calculating result Y is represented by using the mantissa m y , the integer part I x and a sign S y whose value is 0. The exponential calculating result Y is represented in the following format: (−1) Sy ·2 Ey ·m y , where S y is the sign whose value is 0 (referring to the equation 8), E y is the integer part I x (referring to the equation 6), m y is the mantissa and 1≦m y <2.
FIG. 3 is a schematic diagram showing the transforming device according to the present invention. The transforming device 10 , as shown in FIG. 3 , comprises a shifting device 12 , a check device 14 and a decision device 16 . The shifting device 12 receives the exponent of the floating-point number E x and the mantissa of the floating-point number m x and shifts the mantissa of the floating-point number m x according to the exponent of the floating-point number E x . When the exponent of the floating-point number E x is a positive number, the mantissa of the floating-point number m X is shifted left. For example, if the exponent of the floating-point number E x is 5, the mantissa of the floating-point number m X is shifted left 5 bits. When the exponent of the floating-point number E x is a negative number, the mantissa of the floating-point number m X is shifted right. For example, if the exponent of the floating-point number E x is −1, the mantissa of the floating-point number m X is shifted right 1 bits. The result of the shifting device 12 is divided into two parts, the integer part and the fraction part, denoted by I SC and F SC respectively.
If the exponent of the floating-point number E x is too large, the shifting device 12 will be overflowed. The check device 14 checks the value of the exponent of the floating-point number E x in the shifting device 12 to determine when to output an error signal Err. The decision device 16 receives the integer part I SC and the sign of the floating-point number S x . Besides, the decision device 16 decides the sign of the integer part I SC according to the sign of the floating-point number S x to produce the integer part I X for outputting from the transforming device 10 . When the sign of the floating-point number S x is 1, I X =−I SC , otherwise, I X =I SC . The fractional part F SC outputted from transforming device 10 is the fractional part F x .
›DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT · 2 of 2
FIG. 4 is a schematic diagram showing the apparatus for calculating an exponential calculating result of a floating-point number according to the embodiment of the present invention. The apparatus 200 , as shown in FIG. 4 , comprises a shifting device 12 , a check device 14 , a decision device 16 , three exponential tables 20 1 ˜20 3 , and a multiplier 30 . The embodiment of the present invention is used to calculate an exponential calculating result Y for the base 2 floating-point number X, the exponential calculating result Y being given by: Y=2 X . The floating-point number X is represented in the following format: X=(−1) Sx ·2 Ex ·m x . S x is the sign of the floating-point number X with one bit. When the floating-point number X is a positive number, the sign S x is 0. When the floating-point number X is a negative number, the sign S x is 1. E x is the exponent of the floating-point number X with 8 bits. m x is the mantissa of the floating-point number X with 23 bits and 1≦m x <2.
To find the exponential calculating result Y, the first step in the present invention is to divide X into an integer part I x and a fractional part F x . The integer part I x is an 8-bit number. The fractional part F x is a 23-bit number. First, the shifting device 12 receives the exponent of the floating-point number E x and the mantissa of the floating-point number m x and shifts the mantissa of the floating-point number m x according to the exponent of the floating-point number E x . When the exponent of the floating-point number E x is a positive number, the mantissa of the floating-point number m X is shifted left. For example, if the exponent of the floating-point number E x is 5, the mantissa of the floating-point number m X is shifted left 5 bits. When the exponent of the floating-point number E x is a negative number, the mantissa of the floating-point number m X is shifted right. For example, if the exponent of the floating-point number E x is −1, the mantissa of the floating-point number m X is shifted right 1 bits. The output from the shifting device 12 are the integer part I SC and the fraction part F SC .
If the exponent of the floating-point number E x is too large, the shifting device 12 would be overflowed. The check device 14 checks the value of the exponent of the floating-point number E x in the shifting device 12 to determine when to output an error signal Err. The error signal Err includes an “overflow” signal and an “underflow” signal. If the exponent of the floating-point number E x decision is greater than 7, the mantissa of the floating-point number m x must be shifted left more than 7 bits. Therefore, the check device 14 output the “overflow” signal. If the exponent of the floating-point number E x decision is smaller than −23, the mantissa of the floating-point number m X must be shifted light more than 23 bits. Therefore, the check device 14 output the “overflow” signal.
The decision device 16 receives the integer part I SC and the sign of the floating-point number S x . The decision device 16 decides the sign of the integer part I SC according to the sign of the floating-point number S x to produce the integer part I X for outputting from transforming device 10 . When the sign of the floating-point number S x is 1, I X =−I SC , otherwise, I X =I SC . The fractional part F SC outputted from the shifting device 12 is the fractional part F x and the integer part I x is an exponent of the exponential calculating result (Y) E y (referring to the equation 6).
The fractional part F x is a 23-bit number and is divided into 3 parts which have 8, 8 and 7 bits respectively and where 23=8+8+7. Each of the exponential tables 20 1 ˜20 3 receives one of the three parts divided from the fractional part F x and looks up the table to output a result. The multiplier 30 receive all results from the exponential tables 20 1 ˜20 3 and output a mantissa of the exponential calculating result (Y) m y .
Referring to the equation 7:
m y = 2 F x = ∏ 1 2 A 1 · 2 N i - N = ∏ 1 T 1
In the embodiment, 1≦i≦3 and 3 is the number of the exponential tables.
m y = ∏ 1 T 1 = T 1 × T 2 × T 3 = 2 A 1 · 2 - 8 × 2 A 2 · 2 - 16 × 2 A 3 2 - 23 ( 9 )
where T 1 =2 A 1 2 −8 , A 1 is the first part of the three parts divided from the fractional part F x and is a 8-bit number; T 2 =2 A 2 2 −16 , A 2 is the second part of the three parts divided from the fractional part F x and is a 8-bit number; T 3 =2 A 3 ·2 −23 , A 3 is the third part of the three parts divided from the fractional part F x and is a 7-bit number.
Moreover, the exponential calculating result Y is a positive number. Therefore, a sign of the exponential calculating result (Y) S y is 0.
Finally, the exponential calculating result Y is represented by using m y , E y and S y . The exponential calculating result Y is represented in the following format: (−1) Sy ·2 Ey ·m y , where S y is the sign of the exponential calculating result, E y is the exponent of the exponential calculating result, m y is a mantissa of the exponential calculating result and 1≦m y <2.
While the invention has been described by way of example and in terms of the preferred embodiment, it is to be understood that the invention is not limited to the disclosed embodiments. On the contrary, it is intended to cover various modifications and similar arrangements as would be apparent to those skilled in the art. Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements.
Claims as granted
20 claimsLog in to read the claims of this application.
Log in to unlockClassifications
4 codes- G06F1/035
- G06F7/556
Claim changes
SoonSee which claims were amended, added or cancelled during examination, with every added and removed word marked.
The published claims of this application are not paired with the granted ones in what we hold.
File wrapper
See the full prosecution history — every USPTO and applicant action on this file, in order.
Log in to unlockDocuments
Log in to open the documents of this file: the application as filed, every office action and response, the notice of allowance.
Log in to unlockChain of title
See the full assignment history — every owner this patent has passed through, with recordation dates and reel/frame numbers.
Log in to unlock