[Haskell-cafe] Accuracy of Data.Number.Fixed

Imants Cekusins imantc at gmail.com
Sat Mar 5 08:26:01 UTC 2016


> I prefer the Decimal library for currency.

here is another option to consider:

data Cur = Eur | ...
data Money = Mint Cur Int | Mtup Cur (Int,Int)

precision::Cur -> Int
precision Eur = 2
precision _ = 2

€ 10.02 would be:
Mint Eur 1002
Mtup Eur (10,2)

This adds overhead to computations. However precision and correct currency
is guaranteed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160305/67cad0e4/attachment.html>


More information about the Haskell-Cafe mailing list