Decimal Arithmetic Specification, version 1.70
Copyright (c) IBM Corporation, 2009. All rights reserved. ©
 7 Apr 2009 
[previous  contents]

This appendix is not part of the specification. It documents changes to
the combined arithmetic specification, including changes to the earlier
twolayer specifications.
Changes with draft number 0.nn refer to changes in the original base
specification since the first public draft of that specification (0.65,
26 Jul 2000).
Changes with draft number x.nn (for example, x.40) refer to changes in
the original extended specification (inserted in their chronological
position) since the first public draft of that specification (0.30, 9
Aug 2000).
Changes with version number 1.nn refer to changes in the combined
arithmetic specification.

The rules constraining any limits applied to the exponent of a
number have been added.

Minor corrections and clarifications have been added.

A number produced by the tonumber conversion operation has a
sign of zero if the coefficient is 0; similarly,
arithmetic operations cannot produce a result of 0.
These rules allow concrete representations comprising two simple
integers. Note that the Extended specification provides a mechanism
for preserving and producing 0.

The Exceptional conditions section has been extended
to separate out more exceptions and to align them with IEEE 854.

The names of some operations have been changed to achieve a consistent
style.

Minor corrections and clarifications have been added.

The rules constraining the limits applied to the exponent of a
number have been corrected (E_{min} did not
take into account the length of the coefficient).

The rules for converting a number to a scientific
string have been rephrased and corrected (the previous rules
incorrectly converted some zero values).

The Exceptional conditions section has been
alphabetized, and the Invalid context condition has been added.

Minor corrections, clarifications, and additional examples have been
added.

The rounddown (truncation) rounding algorithm has been added.

The rules constraining the righthand operand of the power
operation have been clarified, and the Invalid operation
condition has been added for reporting errors.

The rules for reporting underflow or overflow during a power
operation to a negative power have been specified.

The rules for preserving integers and removing insignificant
zeros have been clarified.

Minor clarifications and additional examples have been added.

The
Exceptional conditions section has been
revised and sorted. Additional cases where the Invalid
operation condition can be raised have been identified, and the
Invalid context condition has been added.

Subnormal numbers are explicitly permitted as operands and for results,
provided that special values are also permitted.

The string representations of NaN values have been changed to conform to
recent discussions of the IEEE 754R committee (further changes
may be necessary).

Minor corrections and clarifications have been made.
 The significand of a number has been renamed from integer
to coefficient, to remove possible ambiguities.

The rescale operation has been added,
because it is available in most existing implementations in some form
and is required for many formatting operations. It needs to be part of
the base specification because it uses the parameters of the
context.

The treatment of zeros with exponents or fractional parts in the
tonumber conversion has been corrected.

Minor clarifications and editorial changes have been made.
 The significand of a number has been renamed from integer
to coefficient, to remove possible ambiguities.

The treatment of zeros with exponents or fractional parts in
toextendednumber has been clarified.
 The rounded condition (with associated signal
and trapenabler) has been added.

The specialvalues flag in the context has been renamed
extendedvalues to better reflect its effect and avoid
confusion (the term special values refers only to infinities
and NaNs).

In order to permit more efficient implementations, the specification no
longer requires that special and extended values raise an Invalid
operation condition if a context with a extendedvalues of 0 is
in use.

For the same reason, extended zeros can no longer have nonzero
exponents; in extended operations the precision of a zero should be
ignored.

Similarly, NaNs can no longer have a sign of 1.
(An implementation can allow signed NaNs, but they would not be
visible using the conversions specified.)

The string conversion from [0,sNaN] has been changed
to "sNaN", as proposed in recent IEEE 754R discussions.

Minor corrections and clarifications have been made, and additional
examples have been added.

If the divisor of the remainder operation is 0, an Invalid
operation condition is raised (instead of Division by zero), for
compatibility with IEEE 854.

Minor clarifications and editorial changes have been made.

The operation of the power and rescale operators has
been clarified.

The behaviors of the Overflow and Underflow exceptional conditions have
been clarified.

The trapresult parameter of the context has been
removed, as it is no longer needed for the exceptional conditions as
specified.

Additional cases where a result of –0 is possible have been
documented.

Minor corrections and clarifications have been made, additional
examples have been added, and differences from IEEE 854 have been
identified.

The definition of the rescale operation has been changed so the
the exponent is always set as specified, even if the coefficient is 0.

Minor clarifications and editorial changes have been made.

The operation of the rescale operator has been extended to
match the base specification (the exponent is now always set as
given, even if the coefficient is 0).
This version combines the original base and extended specifications.
There are necessarily extensive editorial changes. In addition, the
following significant technical changes have been made:

The abs, max, min, and trim
operators have been added.

A precision setting may now have a lower bound as well as
an upper bound. This permits ‘fixed precision’ implementations,
for example, in hardware.

The symbols E_{min} and E_{max} have been redefined
to match the usage in IEEE 854 (that is, they now refer to the
adjusted exponent).

The divide operator no longer trims trailing zeros
automatically. The trim operator has been added to provide
this capability independently.

The calculation of the sign, coefficient, and
exponent has been separately detailed for addition,
subtraction, multiplication, and division.

Zero values accepted by tonumber and produced by various
operations may now have a nonzero exponent.

The rescale operator now accepts a infinite lefthand operand.
This has allowed the roundtointeger operator to be defined as
a special case of rescale.

The power operator is marked as ‘under review’; it may be
redefined or removed in a later version. (It is currently included
because it defines the results as presented in power.decTest.)

The specification allowed subnormal numbers to be more precise than
permitted by IEEE 854. It has been changed to enforce a minimum
exponent of E_{tiny}; this exponent will also be used
when a conversion or calculation underflows to zero.

The Underflow condition is now raised according to the IEEE 854
untrapped underflow criteria (instead of according to the IEEE 854
trapped criteria).
That is, underflow is now only raised when a result is both subnormal
and inexact.

The Subnormal condition has been added, to allow detection of subnormal
results even if Underflow is not raised.

If an overflow or underflow occurs, the Overflow or Underflow conditions
are raised, respectively, instead of special conversion conditions.
This aligns the specification more closely with IEEE 854.

The power operator has been changed to allow subnormals after
raising a number to a negative power.

The tonumber conversion has been enhanced to round
the converted coefficient (if necessary) instead of raising
overflow.

Minor clarifications and editorial changes have been made.

The normalize operation has been added; it reduces a number
to its shortest (coefficient) form. (This replaces the trim
operator, which only removed trailing fractional zeros.)

The definition of the squareroot operation has been simplified
and now returns a result which is independent of the rounding mode in
the context.
This allows simpler implementations, and also
allows the use of Hull and Abrham’s variableprecision algorithm.^{[1]}

Input operands to the arithmetic operations are no longer rounded before
use (this rounding, and the associated Lost digits condition, can
therefore only occur in the X3.274 subset arithmetic).
This change aligns the arithmetic with Java unlimited arithmetic, and
also significantly simplifies hardware implementations which provide
precision control.

Minor clarifications and editorial changes have been made.

The description of the compare operation has been clarified;
its result is always exact and unrounded.

Two errors in the description of the divide operation have been
corrected (‘dividend’ and ‘divisor’ were swapped in the second
While loop, and the calculation of the exponent when the dividend is
zero was described incorrectly).

Changes have been made to accomodate the proposed decimal formats agreed
by the IEEE 754r committee; in particular, E_{min} can now be
–E_{max}±1.

The sign on a NaN is no longer required to be 0; it is now ignored (as
in IEEE 754).

A new context flag, clamped, has been added.

Minor clarifications and editorial changes have been made.
The description of the divide algorithm has been simplified (the
algorithm is unchanged), and minor editorial corrections have been made.
The following changes have been made to improve the consistency of some
operations:

The condition raised when the result of a rescale operation
cannot fit has been changed from Overflow to Invalid operation. This
better fits the description in IEEE 854, and avoids the problem of
Overflow rebiasing if the condition is trapped and an implementation
provides the alternative result.

The description of the squareroot operation has been expanded
and changed to follow the same rules as the divide operator (briefly, the
result with an exponent closest to the ideal exponent is used if the
result is exact, otherwise the result will have precision
digits).

The result after dividing a zero by a nonzero divisor has been
redefined to match the general rules for the divide operation.
These rules are now included as a note.
Following discussions at the May 2003 IEEE 754 revision committee
meeting, the following changes have been made:

The term quantum has been introduced. This is the value of a
unit in the least significant digit of the coefficient of a finite
number.

The rescale operation has been renamed quantize. This
has identical semantics except that the second operand specifies the
desired quantum by example, which allows a faster implementation in most
cases.

The ideal exponent for the squareroot operator is now
floor(e/2), where e is the exponent of the operand.
This is a better match to actual behavior of algorithms.
Following discussions at the June 2003 IEEE 754 revision committee
meeting, the following change has been made:

The roundtointeger operator has been replaced
by the roundtointegralvalue operator.
The latter is more forgiving (no flags are set and no error is possible
unless the operand is signaling NaN, and infinite values are allowed)
but does not guarantee that the exponent of a finite result is 0 (it may
be positive).
To convert to an integer where the exponent must be 0, use the
quantize operator.

The samequantum operator has added; this checks that two
numbers have the same quantum (exponent) and is the operator now in the
draft IEEE 754 revision.

The definition of toengineeringstring has been enhanced to
match the JSR13 proposed final specification: zeros preserve the
original exponent.

The notion of optional diagnostic information associated with NaNs,
as described in IEEE 854 §6.2., is now formalized. In particular,
such information has limits, is propagated through numeric operations,
and has a specific string representation which preserves onetoone
mapping.

Similarly, signs are permitted on NaNs and are propagated in the same
way as diagnostic information.

Minor clarifications and editorial changes have been made.
The quantize operator with two infinite arguments is no longer
an Invalid operation, consistent with the samequantum
operator.

The quantize operator will never raise Underflow.

Minor clarifications and editorial changes have been made.

The max and
min
operations follow the rules in the current IEEE 754 revision draft:
 if one operand is a quiet NaN and the other is number, then the
number is always returned
 if both operands are finite and equal in numerical value then an
ordering is applied: if the signs differ then
max returns the operand with the positive sign and
min returns the operand with the negative sign; if the signs are
the same then the exponent is used to select the result.

Minor clarifications and extra examples have been added.

Minor editorial changes have been made.
The changes in this version add most of the new functionality
required to comply with the draft IEEE 754 revision.

The following seven operations have been added to the Arithmetic
operations section:
comparesignal,
fusedmultiplyadd,
maxmagnitude,
minmagnitude,
nextminus,
nextplus,
nexttoward,
roundtointegralexact.

Twentyseven miscellaneous operations have been added, in a new
Miscellaneous operations section. These are nonarithmetic,
but their results can all be expressed as decimal numbers or strings.

The samequantum operation has been moved to the
Miscellaenous operations section.

Minor clarifications and editorial changes have been made.
Note that some of these operations could still change their
definition as the IEEE 754r draft is still in ballot.

The IEEE 754 standard was approved in June 2008, so some aspects of
this document are no longer proposals and have been updated to
reflect the new status of the standard.

IEEE 754 has added the constraint that
E_{min} = 1–E_{max}.

The requirements of IEEE 854 for the use of the
terms single precision and double precision have
been removed because in the last 21 years these terms have become
synonymous with particular sizes of encodings (32bit and 64bit
respectively).

The rounding mode round05up has been added. This permits
arithmetic at shorter lengths to be carried out in a fixedprecision
environment without double rounding.

The maxmagnitude and minmagnitude operations have
been changed to match the operations in IEEE 754.

The normalize operation has been renamed reduce to
avoid confusion with normal numbers.

All references to the General Decimal Arithmetic website have been updated
to
http://speleotrove.com/decimal
(its new location).

Various clarifications and editorial changes have been made.
The document is now formatted using OpenOffice (generated from GML),
for improved PDF files with bookmarks, hot links, etc. There are no
technical changes.
Footnotes:
[1] 
See Properly Rounded Variable Precision Square Root, T. E. Hull
and A. Abrham, ACM Transactions on Mathematical Software, Vol 11 #3,
pp229237, ACM, September 1985.

[previous  contents]