Decimal Testcases, version 2.44
Copyright (c) IBM Corporation, 2009. All rights reserved. ©
|7 Apr 2009
|[previous | contents | next]
This section describes the testcases included in the testcase package
(dectest.zip), and their history.
The following groups cover the base arithmetic operations of the
||Tests the abs operation.
||Tests the add operation, including both positive and negative
numbers for the operands.
||Test the compare and comparesig operations.
||Tests the divide operation.
||Tests the divideint operation.
||Tests the fma (fused multiply-add) operation.
||Test the max and maxmag operations.
||Test the min and minmag operations.
||Tests the minus operation.
||Tests the multiply operation.
||Tests the quantize operation.
||Tests the reduce operation (previously named
||Tests the remainder operation.
||Tests the remaindernear (IEEE remainder) operation.
||Tests the rescale operation.
||Tests the subtract operation.
||Test the round-to-integral operations.
The following groups cover the mathematical functions of the
||Tests the exp function.
||Tests the ln function.
||Tests the log10 function.
||Test the power operation.
||Tests the squareroot function.
The following groups cover the logical and shifting functions of the
||Tests the and (digit-wise logical and) operation.
||Tests the invert (digit-wise logical invert) operation.
||Tests the or (digit-wise logical or) operation.
||Tests the rotate (coefficient rotation) operation.
||Tests the shift (coefficient shifts) operation.
||Tests the xor (digit-wise logical xor) operation.
The following groups cover miscellaneous functions of the
||Tests the class (classification) operation.
||Test the total-ordering operations.
|copy, copyabs, copynegate, copysign
||Test the quiet copy and sign-manipulation operations.
||Tests the logb (exponent extract) operation.
|nextminus, nextplus, nexttoward
||Test the select-next-value operations.
||Tests the samequantum operation.
||Tests the scaleb (exponent manipulation) operation.
The following groups cover more general aspects of the operations:
||Tests the base string conversions (toSci and toEng
operations), including strings which are not valid numbers.
||Tests edge cases for the inexact and rounded
conditions, using a selection of operations.
||4000 randomly-generated tests, using
the add, compare, divide, divideint,
multiply, power, remainder, and subtract
||Tests the different rounding modes. Each rounding mode is
tested for each of the major operations.
||Tests the trim operation.
Three testcase groups collect together a number of testcase groups
for each of the three main decimal encodings for decimal
||Includes testcase groups for the ‘decimal32’ decimal data
type (7 digits, maximum exponent +96).
The groups included in decSingle all have names starting with
the letters ds, followed by a word corresponding to the
operations they test.
||Includes testcase groups for the ‘decimal64’ decimal data
type (16 digits, maximum exponent +384).
The groups included in decDouble all have names starting with
the letters dd, followed by a word corresponding to the
operations they test.
||Includes testcase groups for the ‘decimal128’ decimal data
type (34 digits, maximum exponent +6144).
The groups included in decQuad all have names starting with
the letters dq, followed by a word corresponding to the
operations they test.
Four testcase groups are designed for testing the boundary conditions
and encodings associated with the concrete representations
for decimal arithmetic and a further group includes random tests for
boundary conditions around 32 digits:
||Tests clamped operations, independent of format.
||Tests for the ‘decimal32’ decimal data type (7 digits, maximum
included in decSingle.
||Tests for the ‘decimal64’ decimal data type (16 digits, maximum
included in decDouble.
||Tests for the ‘decimal128’ decimal data type (34 digits, maximum
included in decQuad.
||2400 tests, as in the randoms group, with precisions 31
through 33 and maximum exponent +9999.
All the above groups appear with the name as shown above – in
these groups testcases are run with the extended directive
set to 1; these testcases are in the file
A subset of these groups also appears with the name as shown above
with the suffix 0 – in these groups the extended
directive is set to 0; these testcases are in the file
This separation makes it easier to test the full or subset
The final testcase simply runs all the testcases described above:
||Runs all the testcases described above (over 64,000 in all).
(Again, a testall0 group runs the tests where the
extended directive is set to 0. This adds a further
Coverage of these testcases is (of course) not exhaustive. Instead, the
testcases assure the basic operations of the arithmetic and concentrate
on ‘difficult cases’; those tests where the result may not be
immediately obvious, or where some implementation in the past has shown
The tests in the testcase groups are derived from a number of sources,
and are intended to cover the paths and edge cases found in:
- Testcases and examples used by the X3 (now NCITS) J18
committee (1991+) which developed the ANSI standard X3.274-1996.
- IBM VM/CMS S/370 Rexx implementation testcases (1981+)
- IBM Vienna Laboratory Rexx compiler testcases (1988+)
- NetRexx testcases (1996+)
- DiagBigDecimal – the open source testcases for
the com.ibm.math.BigDecimal Java class (1997+)
- The decNumber reference implementation testcase library (2000+)
- New testcases, e.g., for the typical concrete representations’ edge
cases, for extended values, operations, and logical and mathematical
functions, and the random tests.
The authoritative sources for how the underlying operations should work
- for the subset decimal arithmetic:
ANSI X3.274-1996 (plus errata, 1997–2001)
- for conversions, conditions, and rounding modes, and the precise
definition of result coefficients: the General
Decimal Arithmetic Specification.
for floating-point arithmetic, including subnormal and special
values (but excluding the deviations noted in the General Decimal
IEEE standard 754-2008,
Please send suggestions for improvements to the testcases to the author,
[previous | contents | next]