| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Haskus.Number.FixedPoint
Description
Fixed-point numbers
Synopsis
- newtype FixedPoint w (i :: Nat) (f :: Nat) = FixedPoint (BitFields w '[BitField i "integer" w, BitField f "fractional" w])
- getFixedPointBase :: FixedPoint w i f -> w
- fromFixedPointBase :: forall w i f. w -> FixedPoint w i f
- toFixedPoint :: forall a w (n :: Nat) (d :: Nat). (RealFrac a, BitSize w ~ (n + d), KnownNat n, KnownNat d, Bits w, Field w, Num w, Integral w) => a -> FixedPoint w n d
- fromFixedPoint :: forall a w (n :: Nat) (d :: Nat). (RealFrac a, BitSize w ~ (n + d), KnownNat n, KnownNat d, Bits w, Field w, Num w, Integral w) => FixedPoint w n d -> a
Documentation
newtype FixedPoint w (i :: Nat) (f :: Nat) Source #
Unsigned fixed-point number
* w is the backing type
* i is the number of bits for the integer part (before the radix point)
* f is the number of bits for the fractional part (after the radix point)
>>>:set -XDataKinds>>>import Data.Word>>>fromIntegral 0 :: FixedPoint Word32 16 160 % 1
>>>fromIntegral 10 :: FixedPoint Word32 16 1610 % 1
Constructors
| FixedPoint (BitFields w '[BitField i "integer" w, BitField f "fractional" w]) |
Instances
getFixedPointBase :: FixedPoint w i f -> w Source #
Get base value
fromFixedPointBase :: forall w i f. w -> FixedPoint w i f Source #
Set base value