Decimal Arithmetic Specification, version 1.11
Copyright (c) IBM Corporation, 2003. All rights reserved. ©
28 Feb 2003
[previous | contents | next]

Appendix A – The X3.274 subset

The full specification in the body of this document defines a decimal floating-point arithmetic which gives exact results and preserves exponents where possible. If insufficient precision is available for this, then numbers are handled according to the rules of IEEE 854. The use of IEEE 854 rules implies that special values (infinities and NaNs) are allowed, as subnormal values and the value –0.

For some applications and programming languages (especially those intended for use by people who are not mathematically sophisticated), it may be appropriate to provide an arithmetic where infinite, NaN, or subnormal results are always treated as errors, –0 results are hidden, and other (largely cosmetic) changes are provided to aid acceptance of results.

The arithmetic defined in ANSI X3.274 is such an arithmetic; this appendix describes the differences between this and the full specification. Implementations which support this subset explicitly might provide the subset behavior under the control of a parameter in the context[1]  or might provide a different interface (additional or parameterized methods, for example).

Simplified number set

In the subset arithmetic, a reduced set of number values is supported and (where appropriate) numbers with positive exponents have their exponent reduced to zero. Specifically:

Operation differences

In the subset arithmetic, operands are rounded before use if necessary (as in Numerical Turing[4]  and Rexx), the Lost digits condition is added to the context, the results of some operations are trimmed, the rounding rule after a subtraction is less conservative, and raising 0 to the power 0 is not treated as an error. Specifically:

Exceptional condition and rounding mode rules

In the subset arithmetic, exceptional conditions other than the informational conditions (Lost digits, Inexact, Rounded, and Subnormal) must be treated as errors, and results after these errors are undefined. Special values and subnormal numbers, therefore, are not part of the arithmetic.

In the subset, only the Lost digits trap enabler is required. Inexact, Rounded, and Subnormal trap enablers are optional, and the others are (in effect) always set. Similarly, the status bits in the context are optional.

Only the round-half-up rounding mode is required.

[1] The decNumber package, for example, provides the subset behavior if the extended bit is set to 0.
[2] This rule, together with the to-number definition, ensures that numbers with values such as -0 or 0.0000 will not result from general operations in the subset arithmetic. This allows a concrete representation for the subset to comprise simply two integers in twos complement form.
[3] The rule preserves integers as specified by ANSI X3.274, and in particular ensures that the results of the divide and divide-integer operations are identical when the result is an exact integer.
[4] See: T. E. Hull, A. Abrham, M. S. Cohen, A. F. X. Curley, C. B. Hall, D. A. Penny, and J. T. M. Sawchuk, Numerical Turing, SIGNUM Newsletter, vol. 20 #3, pp26-34, ACM, May 1985.

[previous | contents | next]