Decimal Testcases Copyright (c) IBM Corporation, 2002. All rights reserved. © | Draft of 5 Jul 2002
[previous | contents | next]

# Notes

This section describes the testcases included in the testcase package (`decTest.zip`), and their history.

### Testcase groups and coverage

The following groups cover the operations of the specification.

Group | Description

`abs`
Tests the `abs` operation.
`add` | Tests the `add` operation, including both positive and negative numbers for the operands.
`base` | Tests the base string conversions (`toSci` and `toEng` operations), including strings which are not valid numbers.
`compare` | Tests the `compare` operation.
`divide` | Tests the `divide` operation.
`divideint` | Tests the `divideint` operation.
`integer` | Tests the `integer` (round-to-integer) operation.
`max` | Tests the `max` operation.
`min` | Tests the `min` operation.
`minus` | Tests the `minus` operation.
`multiply` | Tests the `multiply` operation.
`remainder` | Tests the `remainder` operation.
`remaindernear` | Tests the `remaindernear` (IEEE remainder) operation.
`rescale` | Tests the `rescale` operation.
`subtract` | Tests the `subtract` operation.
`trim` | Tests the `trim` operation.

The following groups cover more general aspects of the base operations.

Group | Description
`inexact` | Tests edge cases for the `inexact` and `rounded` conditions, using a selection of operations.
`power` | Tests the `power` operation (currently under review).
`randoms` | 4000 randomly-generated tests, using the `add`, `compare`, `divide`, `divideint`,`multiply`, `power`, `remainder`, and `subtract` base operations.
`rounding` | Tests the different rounding modes. Each rounding mode is tested for each of the major operations.

Two testcase groups are designed for testing the boundary conditions associated with the proposed concrete representations described in the Standard Decimal Arithmetic Encoding document,[1] and a further three include random tests for these representations and for boundary conditions around 32 digits:

Group | Description
`double` | Boundary condition tests for the ‘double precision’ decimal data type (33 digits, maximum exponent +9999).
`randomBound32` | 2400 tests, as in the `randoms` group, with precisions 31 through 33 and maximum exponent +9999.
`randomDouble` | 4000 tests, as in the `randoms` group, for the ‘double precision’ decimal data type (33 digits, maximum exponent +9999).
`randomSingle` | 4000 tests, as in the `randoms` group, for the ‘single precision’ decimal data type (15 digits, maximum exponent +999).
`single` | Boundary condition tests for the ‘single precision’ decimal data type (15 digits, maximum exponent +999).

All the above groups apear twice:

- once with the name as shown above – in these groups the extended directive is set to 1
- once with the name as shown above with the suffix 0 – in these groups the extended directive is set to 0.

This separation makes it easier to test the full or subset arithmetics separately.

The final testcase simply runs all the testcases described above:

Group | Description
`testall` | Runs all the testcases described above (about 40,100 tests).

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 a problem.

### Testcase history

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.[2]
- 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+)
- New testcases, e.g., for the typical concrete representations' edge cases, for extended values and operations, and the random tests.

The authoritative sources for how the underlying operations should work are:

- for base decimal arithmetic: ANSI X3.274-1996 (plus errata, 1997–2001)[3]
- for conversions, conditions, and rounding modes, and the precise definition of result coefficients: the Standard Decimal Arithmetic Specification.[4]
- for extended floating-point arithmetic, including subnormal and special values (but excluding the deviations noted in the Standard Decimal Arithmetic Specification): ANSI/IEEE standard 854-1987.[5]

Please send suggestions for improvements to the testcases to the author, Mike Cowlishaw (`mfc@uk.ibm.com`).

Footnotes:

[1] | See `http://www2.hursley.ibm.com/decimal/deccode.html`
[2] | American National Standard for Information Technology – Programming Language REXX, X3.274-1996, American National Standards Institute, New York, 1996.
[3] | ibid.
[4] | See `http://www2.hursley.ibm.com/decimal/decarith.html`
[5] | IEEE 854-1987 – IEEE Standard for Radix-Independent Floating-Point Arithmetic, The Institute of Electrical and Electronics Engineers, Inc., New York, 1987.

[previous | contents | next]