Copyright | (C) 2013-2015, University of Twente |
---|---|

License | BSD2 (see the file LICENSE) |

Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |

Safe Haskell | Trustworthy |

Language | Haskell2010 |

- data Signed n

# Documentation

Arbitrary-width signed integer represented by `n`

bits, including the sign
bit.

Uses standard 2-complements representation. Meaning that, given `n`

bits,
a `Signed`

`n`

number has a range of: [-(2^(`n`

-1)) .. 2^(`n`

-1)-1]

**NB**: The `Num`

operators perform `wrap-around`

on overflow. If you want
saturation on overflow, check out the `SaturatingNum`

class.

`>>>`

3`maxBound :: Signed 3`

`>>>`

-4`minBound :: Signed 3`

`>>>`

3`1 + 2 :: Signed 3`

`>>>`

-3`2 + 3 :: Signed 3`

`>>>`

3`(-2) + (-3) :: Signed 3`

`>>>`

6`2 * 3 :: Signed 4`

`>>>`

-8`2 * 4 :: Signed 4`

`>>>`

8`(2 :: Signed 3) `times` (4 :: Signed 4) :: Signed 7`

`>>>`

5`(2 :: Signed 3) `plus` (3 :: Signed 3) :: Signed 4`

`>>>`

-5`(-2 :: Signed 3) `plus` (-3 :: Signed 3) :: Signed 4`

`>>>`

3`satPlus SatSymmetric 2 3 :: Signed 3`

`>>>`

-3`satPlus SatSymmetric (-2) (-3) :: Signed 3`