# Decimal: Decimal numbers with variable precision

[ bsd3, library, math ] [ Propose Tags ]

A decimal number has an integer mantissa and a negative exponent. The exponent can be interpreted as the number of decimal places in the value.

## Modules

[Index]

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

#### Maintainer's Corner

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.3.1, 0.4.1, 0.4.2, 0.5.1, 0.5.2 base (>=4 && <4.5), QuickCheck (>=2.4) [details] BSD-3-Clause Paul Johnson, 2011 Paul Johnson paul@cogito.org.uk Revision 1 made by HerbertValerioRiedel at 2016-05-14T20:14:57Z Math by PaulJohnson at 2012-01-15T16:11:57Z Arch:0.5.2, Debian:0.5.1, Fedora:0.5.2, LTSHaskell:0.5.2, NixOS:0.5.2, Stackage:0.5.2, openSUSE:0.5.2 20425 total (135 in the last 30 days) (no votes yet) [estimated by Bayesian average] λ λ λ Docs uploaded by userBuild status unknown

[back to package description]
Variable Precision Decimal Numbers
==================================

The "Decimal" type is mainly intended for doing financial arithmetic
where the number of decimal places may not be known at compile time
(e.g. for a program that handles both Yen and Dollars) and the
application must not drop pennies on the floor.  For instance if you
have to divide $10 between three people then one of them has to get$3.34.

The number of decimal places in a value is represented as a Word8,
allowing for up to 255 decimal places.  Functions preserve precision.
Binary operators return a result with the precision of the most
precise argument, so 2.3 + 5.678 = 7.978.

If you need fixed precision decimal arithmetic where the precision is
known at compile time then Data.Number.Fixed from Lennart Augustsson's
"numbers" package is more likely to be what you want.

QuickCheck Specification
------------------------

Data.Decimal includes a set of QuickCheck properties which act as both
tests and a formal specification (hence their inclusion in the Haddock
documentation).  To run the tests do:

cabal configure --enable-tests
cabal build
cabal test

Data.Decimal is an instance of Arbitrary, for your convenience in