On this page
Data.Fixed
Copyright | (c) Ashley Yakeley 2005 2006 2009 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | Ashley Yakeley <ashley@semantic.org> |
Stability | stable |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Description
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
.
Instances
(Typeable k, Typeable a) => Data (Fixed a) Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Fixed a -> c (Fixed a) Source gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Fixed a) Source toConstr :: Fixed a -> Constr Source dataTypeOf :: Fixed a -> DataType Source dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Fixed a)) Source dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Fixed a)) Source gmapT :: (forall b. Data b => b -> b) -> Fixed a -> Fixed a Source gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixed a -> r Source gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixed a -> r Source gmapQ :: (forall d. Data d => d -> u) -> Fixed a -> [u] Source gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixed a -> u Source gmapM :: Monad m => (forall d. Data d => d -> m d) -> Fixed a -> m (Fixed a) Source gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixed a -> m (Fixed a) Source gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixed a -> m (Fixed a) Source |
|
Enum (Fixed a) Source | Recall that, for numeric types, and likewise In other words, and similarly This is worth bearing in mind when defining evaluates to However, this is not true. On the contrary, similarly to the above implementations of and contains Since: base-2.1 |
Defined in Data.Fixed Methodssucc :: Fixed a -> Fixed a Source pred :: Fixed a -> Fixed a Source toEnum :: Int -> Fixed a Source fromEnum :: Fixed a -> Int Source enumFrom :: Fixed a -> [Fixed a] Source enumFromThen :: Fixed a -> Fixed a -> [Fixed a] Source enumFromTo :: Fixed a -> Fixed a -> [Fixed a] Source enumFromThenTo :: Fixed a -> Fixed a -> Fixed a -> [Fixed a] Source |
|
HasResolution a => Num (Fixed a) Source | Since: base-2.1 |
Defined in Data.Fixed |
|
HasResolution a => Read (Fixed a) Source | Since: base-4.3.0.0 |
HasResolution a => Fractional (Fixed a) Source | Since: base-2.1 |
HasResolution a => Real (Fixed a) Source | Since: base-2.1 |
Defined in Data.Fixed MethodstoRational :: Fixed a -> Rational Source |
|
HasResolution a => RealFrac (Fixed a) Source | Since: base-2.1 |
HasResolution a => Show (Fixed a) Source | Since: base-2.1 |
Eq (Fixed a) Source | Since: base-2.1 |
Ord (Fixed a) Source | Since: base-2.1 |
class HasResolution (a :: k) where Source
Methods
resolution :: p a -> Integer Source
Instances
KnownNat n => HasResolution (n :: Nat) Source | For example, |
Defined in Data.Fixed Methodsresolution :: p n -> Integer Source |
|
HasResolution E0 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E0 -> Integer Source |
|
HasResolution E1 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E1 -> Integer Source |
|
HasResolution E12 Source | Since: base-2.1 |
Defined in Data.Fixed Methodsresolution :: p E12 -> Integer Source |
|
HasResolution E2 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E2 -> Integer Source |
|
HasResolution E3 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E3 -> Integer Source |
|
HasResolution E6 Source | Since: base-2.1 |
Defined in Data.Fixed Methodsresolution :: p E6 -> Integer Source |
|
HasResolution E9 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E9 -> Integer Source |
showFixed :: HasResolution a => Bool -> Fixed a -> String Source
First arg is whether to chop off trailing zeros
Instances
HasResolution E0 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E0 -> Integer Source |
resolution of 1, this works the same as Integer
Instances
HasResolution E1 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E1 -> Integer Source |
resolution of 10^-1 = .1
Instances
HasResolution E2 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E2 -> Integer Source |
resolution of 10^-2 = .01, useful for many monetary currencies
Instances
HasResolution E3 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E3 -> Integer Source |
resolution of 10^-3 = .001
Instances
HasResolution E6 Source | Since: base-2.1 |
Defined in Data.Fixed Methodsresolution :: p E6 -> Integer Source |
resolution of 10^-6 = .000001
Instances
HasResolution E9 Source | Since: base-4.1.0.0 |
Defined in Data.Fixed Methodsresolution :: p E9 -> Integer Source |
resolution of 10^-9 = .000000001
Instances
HasResolution E12 Source | Since: base-2.1 |
Defined in Data.Fixed Methodsresolution :: p E12 -> Integer Source |
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/9.4.2/docs/libraries/base-4.17.0.0/Data-Fixed.html