The significand of a number has been renamed from integer
to coefficient, to remove possible ambiguities.
The decNumberRescale function has been redefined to match the
base specification. In particular its rhs now specifies the
new exponent directly, rather than as a negated exponent.
In general, all functions now return a reference to their primary result
structure.
The decPackedToNumber function now handles only ‘classic’
Packed Decimal format (there must be a sign nibble, which must be the
final nibble of the packed bytes). This improved conversion speed by a
factor of two.
Minor clarifications and editorial changes have been made.
The header files have been reorganized in order to move private type
names (such as Int and Flag) out of the external interface
header files. In the external interface, integer types now use
the stdint.h names from C99.
All but one of the compile-time parameters have been moved to the
‘internal’ decNumberLocal.h header file, and so are
described in a new section.
The decNumberAbs, decNumberMax, and
decNumberMin functions have been added.
Minor clarifications and editorial changes have been made.
The package has been updated to reflect the changes included in the
combined arithmetic specification. These preserve more digits of the
coefficient together with extended zero values if extended in
the context is 1. Notably:
The decNumberDivide and decNumberPower functions do
not remove trailing zeros after the operation.
(The decNumberTrim function can be used to effect this, if
required.)
A non-zero exponent on a zero value is now possible and is preserved
in a manner consistent with other numbers (that is, zero is no longer a
special case).
The decPackedToNumber function has been enhanced to allow zeros
with non-zero exponents to be converted without loss of information.
The decNumberFromString, decSingleFromString, and
decDoubleFromString functions will now round the coefficient of
a number to fit, if necessary. They also now accept subnormal values and
preserve the exponent of a 0. If an overflow or underflow occurs,
the DEC_Overflow or DEC_Underflow
conditions are raised, respectively.
The package has been corrected to ensure that subnormal values are no
more precise than permitted by IEEE 854.
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 DEC_Subnormal condition has been added so that
subnormal results can be detected even if no Underflow condition is
raised.
Minor clarifications and editorial changes have been made.
The decNumberNormalize function has been added, as an operator.
This makes the coefficient of a number as short as possible while
maintaining its numerical value.
The decNumberSquareRoot function has been added. This returns
the exact square root of a number, rounded to the specified
precision and normalized.
When the extended setting is 1, long operands are used without
input rounding, to give a correctly rounded result (without double
rounding).
The DEC_Lost_digits flag can therefore only be set
when extended is 0.
The major change in decNumber version 3 is the replacement of the
decSingle and decDouble formats by the three new formats
decimal32, decimal64, and decimal128.
These formats are now included in an unapproved draft of the proposed
IEEE-SA 754 standard. However, they are still subject to change; use at
your own risk.
Related and other enhancements include:
The exponent minimum field, emin, has been added to the
decContext structure. This allows the unbalanced exponents used in the
new formats.
The exponent clamping flag, clamp, has been added to the
decContext structure. This provides explicit exponent clamping as used
in the new formats.
A new condition flag, DEC_Clamped has been introduced.
This reports any situation where the exponent of a finite result has
been limited to fit in the available exponent range.
The header file bcd2dpd.h has been renamed decDPD.h to
better describe its function.
The DECSUBSET tuning parameter has been added. This controls the
inclusion of the code and flags required for subset arithmetic; when set
to 0, the performance of many operations is improved by 10%–20%.
Double rounding which was possible with certain subnormal results has
been eliminated.
This version implements some minor changes which track changes agreed
by the IEEE 754 revision committee.
The decNumberQuantize function has been added. Its function
is identical to decNumberRescale except that the second
argument specifies the target exponent ‘by example’ rather than by
value.
The decNumberQuantize and decNumberRescale functions
now report DEC_Invalid_operation rather
than DEC_Overflow if the result cannot fit.
The decNumberToInteger function has been replaced by
the decNumberToIntegralValue function. This implements the new
rules for round-to-integral-value agreed by IEEE 754r. Notably:
the exponent is only set to zero if the operand had a negative exponent
the Inexact flag is not set.
The decNumberSquareRoot function no longer normalizes. Its
preferred exponent is floor(operand.exponent/2).
This version adds a new function and slightly reorganizes the decimalnn
modules.
The decNumberSameQuantum function has been added.
This tests whether two numbers have the same exponents.
The decimal128.h, decimal64.h, and decimal32.h
header files now check that (if more than one is included) they are
included in order of reducing size. This makes it harder to use a
decNumber structure which is too small.
.
The shared DPD pack/unpack routines have been moved
from decimal32.c to decimal64.c, because the latter is
more likely to be used alone.
The decNumberIsInfinite, decNumberIsNaN,
decNumberIsNegative, and decNumberIsZero functions
have been added to simplify tests on numbers.
These functions are currently implemented as macros.
The decNumberMax and decNumberMin functions have
been altered to conform to the maxnum and minnum
functions proposed by IEEE 754r. That is, a total ordering is
provided for numerical comparisons, and if one operand is a quiet NaN
but the other is a number then the number is returned.
The decimal64FromString function (and the same function for
the other two formats) now uses the rounding mode provided in the
context structure.
Arguments to functions which are ‘input only’ are now
decorated with the const keyword to make the functions
easier and safer to call from a C++ wrapper class.
The performance of arithmetic when DECDPUN<=3 has been improved
substantially; DECDPUN==3 performance is now similar to DECDPUN==4.
An error in the decNumberRescale and decNumberQuantize functions has
been corrected. This returned 1.000 instead of NaN for
quantize(0.9998, 0.001) under a context with precision=3.
The decNumberExp function has been added. This returns
e raised to the power of the operand.
The decNumberLn and decNumberLog10 functions have
been added. These return the natural logarithm (logarithm in base
e) or the logarithm in the base ten of the operand,
respectively.
The decNumberPower function has been enhanced by removing
restrictions; notably it now allows raising numbers to non-integer
powers.
The DECENDIAN tuning parameter has been
added. This allows the compressed decimal formats
to be stored using platform-dependent ordering for better performance
and compatibility with binary formats.
This parameter can be set to 0 to get the same (big-endian) ordering
on all platforms, as in earlier versions of the decNumber package.
The DECUSE64 tuning parameter has been
added. This allows 64-bit integers to be used to improve the
performance of operations when DECDPUN<=4.
This parameter can be set to 0 to ensure only 32-bit integers are
used when DECDPUN<=4.
The compressed decimal formats are widely used with the decNumber
package, so the initial setting of DECDPUN has been changed to
3 (from 4), and DECENDIAN and DECUSE64 are both set to
1 (to use platform ordering and 64-bit arithmetic). These settings
significantly improve the speed of conversions to and from the
compressed formats and the speed of multiplications and other
operations.
Minor clarifications and editorial changes have been made.