Copyright | (c) Ashley Yakeley 2005 2006 2009 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | Ashley Yakeley <[email protected]> |
Stability | experimental |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
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 Source
generalisation of div
to any instance of Real
mod' :: Real a => a -> a -> a Source
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
The type parameter should be an instance of HasResolution
.
Enum (Fixed a) | Since: 2.1 |
Eq (Fixed a) | |
HasResolution a => Fractional (Fixed a) | Since: 2.1 |
Typeable * a => Data (Fixed a) | Since: 4.1.0.0 |
HasResolution a => Num (Fixed a) | Since: 2.1 |
Ord (Fixed a) | |
HasResolution a => Read (Fixed a) | Since: 4.3.0.0 |
HasResolution a => Real (Fixed a) | Since: 2.1 |
HasResolution a => RealFrac (Fixed a) | Since: 2.1 |
HasResolution a => Show (Fixed a) | Since: 2.1 |
class HasResolution a where Source
resolution :: p a -> Integer Source
HasResolution E12 | Since: 2.1 |
HasResolution E9 | Since: 4.1.0.0 |
HasResolution E6 | Since: 2.1 |
HasResolution E3 | Since: 4.1.0.0 |
HasResolution E2 | Since: 4.1.0.0 |
HasResolution E1 | Since: 4.1.0.0 |
HasResolution E0 | Since: 4.1.0.0 |
showFixed :: HasResolution a => Bool -> Fixed a -> String Source
First arg is whether to chop off trailing zeros
HasResolution E0 | Since: 4.1.0.0 |
resolution of 1, this works the same as Integer
HasResolution E1 | Since: 4.1.0.0 |
resolution of 10^-1 = .1
HasResolution E2 | Since: 4.1.0.0 |
resolution of 10^-2 = .01, useful for many monetary currencies
HasResolution E3 | Since: 4.1.0.0 |
resolution of 10^-3 = .001
HasResolution E6 | Since: 2.1 |
resolution of 10^-6 = .000001
HasResolution E9 | Since: 4.1.0.0 |
resolution of 10^-9 = .000000001
HasResolution E12 | Since: 2.1 |
resolution of 10^-12 = .000000000001
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/base-4.10.0.0/Data-Fixed.html