Copyright | (C) 2013-2015, University of Twente |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | Unsafe |
Language | Haskell2010 |
Extensions |
|
- newtype Unsigned n = U {}
- size# :: KnownNat n => Unsigned n -> Int
- pack# :: Unsigned n -> BitVector n
- unpack# :: BitVector n -> Unsigned n
- eq# :: Unsigned n -> Unsigned n -> Bool
- neq# :: Unsigned n -> Unsigned n -> Bool
- lt# :: Unsigned n -> Unsigned n -> Bool
- ge# :: Unsigned n -> Unsigned n -> Bool
- gt# :: Unsigned n -> Unsigned n -> Bool
- le# :: Unsigned n -> Unsigned n -> Bool
- enumFrom# :: KnownNat n => Unsigned n -> [Unsigned n]
- enumFromThen# :: KnownNat n => Unsigned n -> Unsigned n -> [Unsigned n]
- enumFromTo# :: KnownNat n => Unsigned n -> Unsigned n -> [Unsigned n]
- enumFromThenTo# :: KnownNat n => Unsigned n -> Unsigned n -> Unsigned n -> [Unsigned n]
- minBound# :: KnownNat n => Unsigned n
- maxBound# :: KnownNat n => Unsigned n
- (+#) :: KnownNat n => Unsigned n -> Unsigned n -> Unsigned n
- (-#) :: KnownNat n => Unsigned n -> Unsigned n -> Unsigned n
- (*#) :: KnownNat n => Unsigned n -> Unsigned n -> Unsigned n
- negate# :: KnownNat n => Unsigned n -> Unsigned n
- fromInteger# :: KnownNat n => Integer -> Unsigned n
- plus# :: KnownNat (1 + Max m n) => Unsigned m -> Unsigned n -> Unsigned (1 + Max m n)
- minus# :: KnownNat (1 + Max m n) => Unsigned m -> Unsigned n -> Unsigned (1 + Max m n)
- times# :: KnownNat (m + n) => Unsigned m -> Unsigned n -> Unsigned (m + n)
- quot# :: Unsigned n -> Unsigned n -> Unsigned n
- rem# :: Unsigned n -> Unsigned n -> Unsigned n
- toInteger# :: Unsigned n -> Integer
- and# :: Unsigned n -> Unsigned n -> Unsigned n
- or# :: Unsigned n -> Unsigned n -> Unsigned n
- xor# :: Unsigned n -> Unsigned n -> Unsigned n
- complement# :: KnownNat n => Unsigned n -> Unsigned n
- shiftL# :: KnownNat n => Unsigned n -> Int -> Unsigned n
- shiftR# :: KnownNat n => Unsigned n -> Int -> Unsigned n
- rotateL# :: KnownNat n => Unsigned n -> Int -> Unsigned n
- rotateR# :: KnownNat n => Unsigned n -> Int -> Unsigned n
- popCount# :: Unsigned n -> Int
- resize# :: KnownNat m => Unsigned n -> Unsigned m
Datatypes
Arbitrary-width unsigned integer represented by n
bits
Given n
bits, an Unsigned
n
number has a range of: [0 .. 2^n
-1]
NB: The Num
operators perform wrap-around
on overflow. If you want
saturation on overflow, check out the SaturatingNum
class.
>>>
maxBound :: Unsigned 3
7>>>
minBound :: Unsigned 3
0>>>
1 + 2 :: Unsigned 3
3>>>
2 + 6 :: Unsigned 3
0>>>
1 - 3 :: Unsigned 3
6>>>
2 * 3 :: Unsigned 3
6>>>
2 * 4 :: Unsigned 3
0>>>
(2 :: Unsigned 3) `times` (4 :: Unsigned 3) :: Unsigned 6
8>>>
(2 :: Unsigned 3) `plus` (6 :: Unsigned 3) :: Unsigned 4
8>>>
satPlus SatSymmetric 2 6 :: Unsigned 3
7>>>
satMin SatSymmetric 2 3 :: Unsigned 3
0
U | The constructor, |
Accessors
Length information
Type classes
BitConvert
Eq
Ord
Enum (not synthesisable)
Bounded
Num
fromInteger# :: KnownNat n => Integer -> Unsigned n Source
ExtendingNum
Integral
toInteger# :: Unsigned n -> Integer Source
Bits
complement# :: KnownNat n => Unsigned n -> Unsigned n Source