Decimal Testcases, version 2.44 Copyright (c) IBM Corporation, 2009. All rights reserved. © 7 Apr 2009 [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 base arithmetic 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. compare, comparesig Test the compare and comparesig operations. divide Tests the divide operation. divideint Tests the divideint operation. fma Tests the fma (fused multiply-add) operation. max, maxmag Test the max and maxmag operations. min, minmag Test the min and minmag operations. minus Tests the minus operation. multiply Tests the multiply operation. quantize Tests the quantize operation. reduce Tests the reduce operation (previously named normalize). remainder Tests the remainder operation. remaindernear Tests the remaindernear (IEEE remainder) operation. rescale Tests the rescale operation. subtract Tests the subtract operation. tointegral, tointegralx Test the round-to-integral operations.

The following groups cover the mathematical functions of the specification:
 Group Description exp Tests the exp function. ln Tests the ln function. log10 Tests the log10 function. power, powersqrt Test the power operation. squareroot Tests the squareroot function.

The following groups cover the logical and shifting functions of the specification:
 Group Description and Tests the and (digit-wise logical and) operation. invert Tests the invert (digit-wise logical invert) operation. or Tests the or (digit-wise logical or) operation. rotate Tests the rotate (coefficient rotation) operation. shift Tests the shift (coefficient shifts) operation. xor Tests the xor (digit-wise logical xor) operation.

The following groups cover miscellaneous functions of the specification:
 Group Description class Tests the class (classification) operation. comparetotal, comparetotmag Test the total-ordering operations. copy, copyabs, copynegate, copysign Test the quiet copy and sign-manipulation operations. logb Tests the logb (exponent extract) operation. nextminus, nextplus, nexttoward Test the select-next-value operations. samequantum Tests the samequantum operation. scaleb Tests the scaleb (exponent manipulation) operation.

The following groups cover more general aspects of the operations:
 Group Description base Tests the base string conversions (toSci and toEng operations), including strings which are not valid numbers. inexact Tests edge cases for the inexact and rounded conditions, using a selection of operations. randoms 4000 randomly-generated tests, using the add, compare, divide, divideint, multiply, power, remainder, and subtract operations. rounding Tests the different rounding modes. Each rounding mode is tested for each of the major operations. trim Tests the trim operation.

Three testcase groups collect together a number of testcase groups for each of the three main decimal encodings for decimal arithmetic:[1]
 Group Description decSingle 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. decDouble 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. decQuad 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:
 Group Description clamp Tests clamped operations, independent of format. dsEncode Tests for the ‘decimal32’ decimal data type (7 digits, maximum exponent +96); included in decSingle. ddEncode Tests for the ‘decimal64’ decimal data type (16 digits, maximum exponent +384); included in decDouble. dqEncode Tests for the ‘decimal128’ decimal data type (34 digits, maximum exponent +6144); included in decQuad. randombound32 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 dectest.zip

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 dectest0.zip

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 (over 64,000 in all).

(Again, a testall0 group runs the tests where the extended directive is set to 0. This adds a further 16,300 testcases.)

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+)
• 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 are:

• for the subset 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 General Decimal Arithmetic Specification.[4]
• for floating-point arithmetic, including subnormal and special values (but excluding the deviations noted in the General Decimal Arithmetic Specification): IEEE standard 754-2008,[5]

Please send suggestions for improvements to the testcases to the author, Mike Cowlishaw.

Footnotes:
 [1] See http://speleotrove.com/decimal/decbits.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://speleotrove.com/decimal/decarith.html [5] IEEE Std 754-2008 – IEEE Standard for Floating-Point Arithmetic, The Institute of Electrical and Electronics Engineers, Inc., New York, 2008.

[previous | contents | next]