|
General Decimal Arithmetic
[ FAQ | Bibliography | Arithmetic specification | Formats (encodings) | decNumber C implementation and C++ implementation | DFPAL | Testcases | Summary | Densely Packed Decimal | Decimal web links ] |
|
Most computers today support binary floating-point in hardware. While suitable for many purposes, binary floating-point arithmetic should not be used for financial, commercial, and user-centric applications or web services because the decimal data used in these applications cannot be represented exactly using binary floating-point. (See the Frequently Asked Questions pages for an explanation of this, and several examples.)
The problems of binary floating-point can be avoided by using base 10 (decimal) exponents and preserving those exponents where possible. This site describes a decimal arithmetic which achieves the necessary results and is suitable for both hardware and software implementation. It brings together the relevant concepts from a number of ANSI, IEEE, ECMA, and ISO standards, and conforms to the decimal formats and arithmetic in the revised IEEE 754 standard (‘754r’), which was approved in June 2008.
The decimal-encoded formats and arithmetic described in the new IEEE 754 standard now have many implementations in hardware and software (see links below), including:
The combination of formats and arithmetic defined here and in the IEEE 754 standard describe a new decimal data type, in various sizes. Notably, this single data type can be used for integer, fixed-point, and floating-point decimal arithmetic, and the design permits compatible fixed-size and arbitrary-precision implementations. Further, most numeric data in commercial databases are stored in a decimal form (one or two digits per byte), which can be converted to and from the decimal-encoded formats efficiently and easily.
The main features of the arithmetic are summarized below. For the background and rationale for the design of the arithmetic, see Decimal Floating-Point: Algorism for Computers in the Proceedings of the 16th IEEE Symposium on Computer Arithmetic (Cowlishaw, M. F., 2003).
Here you will find our primary documentation and downloads for decimal arithmetic, fixed-size decimal formats (encodings) and their performance, the decNumber reference implementation, the decNumber++ implementation for C++, the DFPAL PowerPC abstraction layer, and the language-independent testcases.
| Arithmetic | Version | Description |
| Specification
[.html | .pdf | .ps] |
1.66 2007.03.13 |
Decimal floating-point arithmetic, with unrounded and integer
arithmetic as a subset (IEEE 754r + IEEE 854 + ANSI X3.274 +
ECMA 334 + Java[TM] 5).
|
| This specification forms the basis for a number of implementations, and also describes the decimal arithmetic in the revised IEEE 754 standard. | ||
| Formats | Version | Description |
| Specification
[.html | .pdf | .ps] |
0.96 2003.02.21 |
Concrete formats (bit encodings) suitable for hardware or software implementation of native decimal datatypes; these provide up to 7, 16, or 34 digits of precision. |
| Performance
[.html | .pdf | .ps] |
1.10 2007.10.19 |
Performance measurements on three implementations that support the encodings described in the IEEE 754 revision. |
| Sample code
[.html] |
1.00 2003.04.10 |
Java[TM] classes which illustrate the decimal encoding of decimal floating-point numbers, and the corresponding decoding. |
| (The earlier ‘Strawman 1’ proposal, implemented as decSingle and decDouble in early versions of the decNumber package, is available for historical interest in PDF form. See also: A Decimal Floating-Point Specification, Schwarz et al., 15th IEEE Symposium on Computer Arithmetic [presentation charts].) | ||
The package is available under a variety of open source and commercial licenses (the ICU license is the least restrictive), and is suitable for little-endian or big-endian systems which support 32-bit (or wider) integers. It is currently in use on dozens of different platforms, including mainframes, PowerPC, x86, and over 20 varieties of Unix.
| decNumber | Version | Description |
| Documentation
[.html | .pdf | .ps] |
3.56 2007.10.12 |
Describes the decNumber package, including a User’s Guide
section with several examples.
(Note that the documentation here may be a more recent version than the downloadable code. If such is the case, check the changes list in the Appendix to determine if this document applies.) |
| International Components for Unicode (ICU)
decNumber C code [errata] |
3.56 2007.10.12 |
The source code (.h and .c
files), together with the examples, the
ICU license, and the documentation in PDF format.
(The package is also mirrored here.) |
| IBM alphaWorks
decNumber C code [errata] |
3.56 2007.10.12 |
The source code (.h and .c
files), together with the examples, the
alphaWorks
license, and the documentation in PDF format.
(This download is on the IBM alphaWorks site. A commercial license for this software is also available there.) |
| GPL open source
decNumber C code decExamples.zip [errata] |
3.53 2007.09.07 |
‘decNumber C code’ links to the open source code (.h and .c files), part of the GCC project (GPL license). ‘decExamples.zip’ contains the example files referred to in the documentation and also the readme.txt file which has suggestions on how to compile and run the examples. |
| More implementations of the arithmetic are listed below. | ||
| decNumber++ | Version | Description |
| IBM alphaWorks
decNumber++ |
1.00 2006.07.11 |
Robert Klarer’s
decNumber++, which implements the interfaces
specified in the forthcoming ISO Technical Report on decimal
arithmetic types in C++:
ISO/IEC
TR 24733: C++ Decimal Floating-Point Arithmetic Extensions.
(This download is on the IBM alphaWorks site.) |
| More implementations of the arithmetic are listed below. | ||
| DFPAL
|
Version | Description |
| Documentation
[.html | as .zip] |
2.20 2008.01.03 |
The DFPAL User’s guide with overview, examples, compilation instructions, FAQ, etc. |
| Download
DFPAL.zip DFPAL.tar.gz |
2.20 2008.01.03 |
The DFPAL source code (.h and .c files), together with the examples, the International Components for Unicode (ICU) license, the documentation in HTML format, etc. |
| Testcases | Version | Description |
| Documentation
[.html | .pdf | .ps] |
2.42 2008.06.21 |
Describes the testcase file format, testcase coverage, and testcase sources. |
| Download
dectest.zip dectest0.zip |
2.57 2007.10.12 |
The extended (dectest.zip) and subset (dectest0.zip) testcase files (containing approximately 81,300 tests). These cover all the operations and conversions described in the specifications, and include tests for the decimal encodings. |
The decimal arithmetic described here combines the requirements of both fixed-point and floating-point arithmetic, giving the following advantages:
|
|
The links below provide background and related information.
Background & Rationale
|
Bibliography
Related Decimal Links
|
| Please send any comments or corrections to Mike Cowlishaw (mfc), mfc@uk.ibm.com |
|
|
Copyright © IBM Corporation 2000, 2008. All rights reserved.
Java is a trademark of Sun Microsystems Inc. | |
| [ IBM home page | Search | Contact IBM | Help | Terms of use | Privacy ] | |
| IBM United Kingdom Limited – Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU |