[Haskell-cafe] Implementation of scaled integers

Twan van Laarhoven twanvl at gmail.com
Tue Feb 13 16:58:14 EST 2007


Stefan Heinzmann wrote:

> Hi all,
> 
> is there a library for Haskell that implements scaled integers, i.e.
> integers with a fixed scale factor so that the scale factor does not
> need to be stored, but is part of the type?

Data.Fixed [1] does exactly that, only it is based on Integer. Using 
fixed point with finite sized integers is more tricky, because you have 
to be careful not to get overflows in intermediate results.

Twan


[1] http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Fixed.html



More information about the Haskell-Cafe mailing list