base- Basic librariesSource codeContentsIndex
MaintainerAshley Yakeley <>

This module defines a "Fixed" type for fixed-precision arithmetic. The parameter to Fixed is any type that's an instance of HasResolution. HasResolution has a single method that gives the resolution of the Fixed type.

This module also contains generalisations of div, mod, and divmod to work with any Real instance.

div' :: (Real a, Integral b) => a -> a -> b
mod' :: Real a => a -> a -> a
divMod' :: (Real a, Integral b) => a -> a -> (b, a)
data Fixed a
class HasResolution a where
resolution :: p a -> Integer
showFixed :: HasResolution a => Bool -> Fixed a -> String
data E0
type Uni = Fixed E0
data E1
type Deci = Fixed E1
data E2
type Centi = Fixed E2
data E3
type Milli = Fixed E3
data E6
type Micro = Fixed E6
data E9
type Nano = Fixed E9
data E12
type Pico = Fixed E12
div' :: (Real a, Integral b) => a -> a -> bSource
generalisation of div to any instance of Real
mod' :: Real a => a -> a -> aSource
generalisation of mod to any instance of Real
divMod' :: (Real a, Integral b) => a -> a -> (b, a)Source
generalisation of divMod to any instance of Real
data Fixed a Source
The type parameter should be an instance of HasResolution.
show/hide Instances
class HasResolution a whereSource
resolution :: p a -> IntegerSource
show/hide Instances
showFixed :: HasResolution a => Bool -> Fixed a -> StringSource
First arg is whether to chop off trailing zeros
data E0 Source
show/hide Instances
type Uni = Fixed E0Source
resolution of 1, this works the same as Integer
data E1 Source
show/hide Instances
type Deci = Fixed E1Source
resolution of 10^-1 = .1
data E2 Source
show/hide Instances
type Centi = Fixed E2Source
resolution of 10^-2 = .01, useful for many monetary currencies
data E3 Source
show/hide Instances
type Milli = Fixed E3Source
resolution of 10^-3 = .001
data E6 Source
show/hide Instances
type Micro = Fixed E6Source
resolution of 10^-6 = .000001
data E9 Source
show/hide Instances
type Nano = Fixed E9Source
resolution of 10^-9 = .000000001
data E12 Source
show/hide Instances
type Pico = Fixed E12Source
resolution of 10^-12 = .000000000001
Produced by Haddock version 2.6.0