Important notice

Decimal has moved to GitHub! Please go to the new project page.

The text below and the code in the dsource repository will no longer be updated.

Welcome to Decimal

This project provides a D programming language implementation of the General Decimal Arithmetic Specification, Version 1.70 (March 2009). (http://www.speleotrove.com/decimal) This specification incorporates the IEEE 754-2008 and IEEE 854-1987 floating-point specifications.

Currently, only an arbitrary-precision floating-point implementation is available. (The specification also applies to fixed-precision decimals: decimal32, decimal64, and decimal128.) The implementation provides all the arithmetic and other operations listed in the specification with the following exceptions:

  • The exp, log and pow functions are not yet implemented. Implementing these is top priority.
  • Logical functions (or, and, not, etc.) are not yet implemented. I presume these are not going to be used much--they will only be included to complete the implementation.
  • Shift and rotate functions are not yet implemented. Ditto for these.
  • There are some (hopefully minor) cases where the implementation is not conformant with the specification.

I'll enter these exceptions as tickets as soon as possible.

Purpose

This project is not intended to provide "the" arbitrary-precision floating point module, although it could conceivably become that over time. This is a first attempt at creating a D language implementation; a strawman for developing the interfaces, classes/structs and methods that should exist in such a module. I do think it would be a mistake to develop an arbitrary-precision floating-point module that didn't conform to the General Decimal Arithmetic Specification.

Limitations

The current implementation compiles with D 2.30. Changes to the compiler introduced in D 2.40 seem to break the underlying bigint module. Changes to the operator overloading introduced in D 2.41 compound the problem.

Speaking of bigint -- the current (as of Mar 2010) Phobos module, written largely by Janice Caron, is due to be replaced by Don Clugston's implementation (which is available now in Tango). Presumably Don's implementation will be compatible with the more current versions of D. I won't worry about getting up-to-date until Don's bigint modules is ported to D2.