| Copyright | (C) 2013-2016 University of Twente |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Clash.Sized.Unsigned
Description
Documentation
data Unsigned (n :: Nat) Source #
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 37>>>minBound :: Unsigned 30>>>read (show (maxBound :: Unsigned 3)) :: Unsigned 37>>>1 + 2 :: Unsigned 33>>>2 + 6 :: Unsigned 30>>>1 - 3 :: Unsigned 36>>>2 * 3 :: Unsigned 36>>>2 * 4 :: Unsigned 30>>>(2 :: Unsigned 3) `mul` (4 :: Unsigned 3) :: Unsigned 68>>>(2 :: Unsigned 3) `add` (6 :: Unsigned 3) :: Unsigned 48>>>satAdd SatSymmetric 2 6 :: Unsigned 37>>>satSub SatSymmetric 2 3 :: Unsigned 30