DFP
Decimal Floating Point
Java class library
|
IEEE 854-1987 Notes and differences
- Radix 10000
IEEE 854 requires the radix to be either 2 or 10. The radix here is
10000, so that requirement is not met, but it is possible that a
subclass can be made to make it behave as a radix 10
number. It is my opinion that if it looks and behaves as a radix
10 number then it is one and that requirement would be met.
The radix of 10000 was chosen because it should be faster to operate
on 4 decimal digits at once intead of one at a time. Radix 10 behaviour
can be realized by add an additional rounding step to ensure that
the number of decimal digits represented is constant.
The IEEE standard specifically leaves out internal data encoding,
so it is reasonable to conclude that such a subclass of this radix
10000 system is merely an encoding of a radix 10 system.
The supplied subclass rossi.dfp.dfpdec hides this
implementation detail and behaves as a decimal number.
- Sub-normal numbers
IEEE 854 also specifies the existance of "sub-normal" numbers. This
class does not contain any such entities. The most significant radix
10000 digit is always non-zero. Instead, we support "gradual underflow"
by raising the underflow flag for numbers less with exponent less than
expMin, but dont flush to zero until the exponent reaches expMin-DIGITS.
Thus the smallest number we can represent would be:
1E(-(minExp-DIGITS-1)*4), eg, for DIGITS=5, minExp=-32767, that would
be 1e-131092.
- Implied Radix point
IEEE 854 defines that the implied radix point lies just to the right
of the most significant digit and to the left of the remaining digits.
This implementation puts the implied radix point to the left of all
digits including the most significant one. The most significant digit
here is the one just to the right of the radix point. This is a fine
detail and is really only a matter of definition. Any side effects of
this can be rendered invisible by a subclass.
|