The Decimal package

[Tags:bsd3, library, test]

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.

[Skip to Readme]


Versions 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.3.1, 0.4.1, 0.4.2
Dependencies base (==4.*), deepseq [details]
License BSD3
Copyright Paul Johnson, 2013
Author Paul Johnson
Category Math
Home page
Uploaded Mon Mar 4 20:00:33 UTC 2013 by PaulJohnson
Distributions Arch:0.4.2, Debian:0.4.2, Fedora:0.4.2, LTSHaskell:0.4.2, NixOS:0.4.2, Stackage:0.4.2, Tumbleweed:0.4.2
Downloads 5221 total (149 in the last 30 days)
0 []
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for Decimal

Readme for Decimal-0.3.1

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

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. To run the tests do:

   cabal configure --enable-tests
   cabal build
   cabal test

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

Version 0.2.1

Fixed "base" dependency.
Put test suite under "cabal test"

Version 0.2.2

Minor fixes to allow compilation under other versions of GHC.

Version 0.2.3

Added instance of NFData from Control.DeepSeq, and hence a dependency
on the deepseq package, thanks to Jeff Shaw (shawjef3 at

Version 0.3.1

Added Typeable, Fractional and RealFrac instances.
Multiplication now returns an exact result, increasing precision if necessary.

These changes alter the API. Hence the increment to the major version number.

Thanks to Alexey Uimanov (s9gf4ult at