IBM® is a registered trademark of International Business Machines Corporation, Armonk, N.Y., U.S.A.
1. Field of the Invention
This invention relates to computer processing systems, and particularly to a method for handling floating point instructions in a computer processing system.
2. Description of Background
There is a problem for a hardware implementation, such as that illustrated generally by IBM's U.S. Pat. No. 5,880,984 having a floating point arithmetic unit for performing independent multiply and add operations in the execution of a multiply-add instruction on three operands A, B, and C, wherein A being the multiplicand, C being the multiplier and B being the addend, and each operand comprising data of a prescribed number p of bits in accordance with a given floating-point precision including one (1) sign bit indicating if a data represents a positive (+) or a negative (−) value, X exponent bits, and y mantissa bits, for the microprocessor arithmetic unit to perform rounding to multiple precisions and create the exactly rounded result as if the machine had performed only one rounding from the infinitely precise intermediate result. In decimal arithmetic employed in microprocessor based computer processing systems, especially those used for financial transactions applications, it is common to round a result to a defined precision which may vary between or within an application. One calculation may need to round a result to 6 digits of precision while another must produce a result to 10 digits of precision, while the underlying hardware produces a result to 16 digits of precision. A mechanism is needed for performing rounding to a variable precision without loss of accuracy caused by rounding twice.
The preferred embodiment of the invention provides a computer processing system with the ability to handle a decimal rounding mode which preserves data information for further rounding to less precision for floating point operations with a round to reround instruction.
Additional features and advantages are realized through the techniques of the present invention. Other embodiments and aspects of the invention are described in detail herein and are considered a part of the claimed invention. For a better understanding of the invention with advantages and features, refer to the description and to the drawings.
The subject matter which is regarded as the invention is particularly pointed out and distinctly claimed in the claims at the conclusion of the specification. The foregoing and other objects, features, and advantages of the invention are apparent from the following detailed description taken in conjunction with the accompanying drawings in which:
The detailed description explains the preferred embodiments of the invention, together with advantages and features, by way of example with reference to the drawings.
This system is useful for financial applications run on microprocessor based computer processing systems, and will be seen to be an improvement to the now standard IEEE 754 Floating Point. It can be proved that a system can round to “p” digits of precision a result that was previously rounded to “2p+2” digits of precision without causing double rounding errors. The current IEEE 754 binary floating point standard defines the significands of single, double, and a proposed quadword format such that this criteria is met (24, 53, and 113 bits in each format). Each format is greater than a little over twice the width of the next smaller precision. There has been developed a current IEEE754 revision developed by a committee which has agreed on decimal floating-point formats of 7, 16, and 34 digits which also satisfy this requirement. When we considered this development we wondered how can a computer system be developed where a user can run applications which round to 10 digits accurately if the original arithmetic operation were rounded to 16 digits. Such an application would now meet the revised requirement, one which does not meet this criteria.
We will describe our improvement with respect to the table of
For binary floating-point there was a solution proposed to create a new rounding mode, but the extension to decimal is not straightforward. For binary floating-point the new rounding mode truncates and logically ORs the sticky bit into the least significant bit.
The preferred embodiment of our invention eliminates the performance bottleneck of updating and reading the floating-point status word of prior applications and provides the capability of secondary roundings up to “p−1” digits of precision where the first rounding was to “p” digits of precision. The mechanism for providing this information is to create a new rounding mode which maintains this information within the result of the first rounded result which was rounded to the hardware format precision. This rounding mode creates a result which will round equivalently to “p−1” digits or less of precision as the original infinitely precise result. By doing this, the extra information is contained completely within the operand and there is no bottleneck in using the floating-point status word. And given that the information is contained within the operand, multiple independent operations can be placed in between these two instructions (the original arithmetic instruction to hardware precision and the subsequent rerounding to lesser precision).
The preferred embodiment of our invention provides a new rounding mode called “round for reround”. The precise result of the arithmetic operation is first truncated to the hardware format precision “p”, forming an intermediate result. If only zeros are dropped during truncation, then the intermediate result is equal to the precise result, and this result is said to be “exact”, otherwise, it is “inexact”. When the intermediate result is inexact and its least significant digit is either zero or five, then that digit is incremented to one or six respectively forming the rounded result. Thus, when the least significant digit of a rounded result is zero or five the result could be construed to be exact or exactly halfway between two machine representations if it were later rounded to one less digit of precision. For all other values, it is obvious that the result is inexact and not halfway between two machine representations for later roundings to fewer than “p” digits of precision. A nice mathematical property of this rounding mode is that results stay ordered and in a hardware implementation it is guaranteed that the incrementation of the least significant digit does not cause a carry into the next digit of the result.
This embodiment could be used by implementations of Decimal Floating-Point format proposed in the next revision to the IEEE 754 Binary Floating-Point Standard and implemented in a hardware implementation of this Decimal Floating-Point format. This a robust method of rounding to lesser precision than the hardware format. It removes any dependencies between writing and reading a single point such as the floating-point status word and instead can be implement in systems providing an interlock between writing and reading operands into registers. With this new interlock mechanism the two instructions could be separated in time by any number of independent instructions.
An example of this is our preferred embodiment of a method to multiply two operands in a 16 digit hardware format but later round the answer to 15 digits in rounding mode where the operand is rounded to the nearest representable number in the target format and in case of a tie is rounded to the lower magnitude. One could also call this rounding mode round half down).
This method can be illustrated as follows:
Using Round for Reround Rounding Mode:
It will be noted that if instead the decimal multiply were rounded toward zero the 16 digit result would be 1.234567890123445
So, in accordance with the preferred embodiment, rounding to less digits accurately involves two functions, 1) using a new rounding mode called round for reround on the original arithmetic instruction in the hardware precision, and then 2) invoking an instruction which specifies a variable rounding precision and possibly explicitly sets the rounding mode which we have called the ReRound instruction.
While the preferred embodiment to the invention has been described, it will be understood that those skilled in the art, both now and in the future, may make various improvements and enhancements which fall within the scope of the claims which follow. These claims should be construed to maintain the proper protection for the invention first described.