GHC.Integer

integer-gmp-0.5.1.0: Integer library based on GMP

Copyright | (c) The University of Glasgow 1994-2008
License | see libraries/integer-gmp/LICENSE
Maintainer | cvs-ghc@haskell.org
Stability | internal
Portability | non-portable (GHC Extensions)
Safe Haskell | None
Language | Haskell2010

GHC.Integer

Contents

- Construct `Integer`s
- Conversion to other integral types
- Helpers for `RealFloat` type-class operations
- Arithmetic operations
- Comparison predicates
- Bit-operations
- Hashing

Description

The `Integer` type.

This module exposes the portable `Integer` API. See GHC.Integer.GMP.Internals for the GMP-specific internal representation of `Integer` as well as optimized GMP-specific operations.

Synopsis

- data Integer
- mkInteger :: Bool -> [Int] -> Integer
- smallInteger :: Int# -> Integer
- wordToInteger :: Word# -> Integer
- integerToWord :: Integer -> Word#
- integerToInt :: Integer -> Int#
- encodeFloatInteger :: Integer -> Int# -> Float#
- floatFromInteger :: Integer -> Float#
- encodeDoubleInteger :: Integer -> Int# -> Double#
- decodeDoubleInteger :: Double# -> (#Integer, Int##)
- doubleFromInteger :: Integer -> Double#
- plusInteger :: Integer -> Integer -> Integer
- minusInteger :: Integer -> Integer -> Integer
- timesInteger :: Integer -> Integer -> Integer
- negateInteger :: Integer -> Integer
- absInteger :: Integer -> Integer
- signumInteger :: Integer -> Integer
- divModInteger :: Integer -> Integer -> (#Integer, Integer#)
- divInteger :: Integer -> Integer -> Integer
- modInteger :: Integer -> Integer -> Integer
- quotRemInteger :: Integer -> Integer -> (#Integer, Integer#)
- quotInteger :: Integer -> Integer -> Integer
- remInteger :: Integer -> Integer -> Integer
- eqInteger :: Integer -> Integer -> Bool
- neqInteger :: Integer -> Integer -> Bool
- leInteger :: Integer -> Integer -> Bool
- gtInteger :: Integer -> Integer -> Bool
- ltInteger :: Integer -> Integer -> Bool
- geInteger :: Integer -> Integer -> Bool
- compareInteger :: Integer -> Integer -> Ordering
- eqInteger# :: Integer -> Integer -> Int#
- neqInteger# :: Integer -> Integer -> Int#
- leInteger# :: Integer -> Integer -> Int#
- gtInteger# :: Integer -> Integer -> Int#
- ltInteger# :: Integer -> Integer -> Int#
- geInteger# :: Integer -> Integer -> Int#
- andInteger :: Integer -> Integer -> Integer
- orInteger :: Integer -> Integer -> Integer
- xorInteger :: Integer -> Integer -> Integer
- complementInteger :: Integer -> Integer
- shiftLInteger :: Integer -> Int# -> Integer
- shiftRInteger :: Integer -> Int# -> Integer
- testBitInteger :: Integer -> Int# -> Bool
- hashInteger :: Integer -> Int#

# Documentation

data Integer Source

Arbitrary-precision integers.

Instances

Eq Integer |
Ord Integer |

# Construct `Integer`s

mkInteger Source

Arguments

:: Bool | sign of integer (`True` if non-negative)
-> [Int] | absolute value expressed in 31 bit chunks, least significant first
-> Integer |

Construct `Integer` value from list of `Int`s.

This function is used by GHC for constructing `Integer` literals.

smallInteger :: Int# -> Integer Source

wordToInteger :: Word# -> Integer Source

# Conversion to other integral types

integerToWord :: Integer -> Word# Source

integerToInt :: Integer -> Int# Source

# Helpers for `RealFloat` type-class operations

encodeFloatInteger :: Integer -> Int# -> Float# Source

floatFromInteger :: Integer -> Float# Source

encodeDoubleInteger :: Integer -> Int# -> Double# Source

decodeDoubleInteger :: Double# -> (#Integer, Int##) Source

doubleFromInteger :: Integer -> Double# Source

# Arithmetic operations

plusInteger :: Integer -> Integer -> Integer Source

minusInteger :: Integer -> Integer -> Integer Source

timesInteger :: Integer -> Integer -> Integer Source

negateInteger :: Integer -> Integer Source

absInteger :: Integer -> Integer Source

signumInteger :: Integer -> Integer Source

divModInteger :: Integer -> Integer -> (#Integer, Integer#) Source

divInteger :: Integer -> Integer -> Integer Source

modInteger :: Integer -> Integer -> Integer Source

quotRemInteger :: Integer -> Integer -> (#Integer, Integer#) Source

quotInteger :: Integer -> Integer -> Integer Source

remInteger :: Integer -> Integer -> Integer Source

# Comparison predicates

eqInteger :: Integer -> Integer -> Bool Source

neqInteger :: Integer -> Integer -> Bool Source

leInteger :: Integer -> Integer -> Bool Source

gtInteger :: Integer -> Integer -> Bool Source

ltInteger :: Integer -> Integer -> Bool Source

geInteger :: Integer -> Integer -> Bool Source

compareInteger :: Integer -> Integer -> Ordering Source

eqInteger# :: Integer -> Integer -> Int# Source

Since: 0.5.1.0

neqInteger# :: Integer -> Integer -> Int# Source

Since: 0.5.1.0

leInteger# :: Integer -> Integer -> Int# Source

Since: 0.5.1.0

gtInteger# :: Integer -> Integer -> Int# Source

Since: 0.5.1.0

ltInteger# :: Integer -> Integer -> Int# Source

Since: 0.5.1.0

geInteger# :: Integer -> Integer -> Int# Source

Since: 0.5.1.0

# Bit-operations

andInteger :: Integer -> Integer -> Integer Source

orInteger :: Integer -> Integer -> Integer Source

xorInteger :: Integer -> Integer -> Integer Source

complementInteger :: Integer -> Integer Source

shiftLInteger :: Integer -> Int# -> Integer Source

shiftRInteger :: Integer -> Int# -> Integer Source

testBitInteger :: Integer -> Int# -> Bool Source

Since: 0.5.1.0

# Hashing

hashInteger :: Integer -> Int# Source

`hashInteger` returns the same value as `fromIntegral`, although in unboxed form. It might be a reasonable hash function for `Integer`, given a suitable distribution of `Integer` values.

Note: `hashInteger` is currently just an alias for `integerToInt`.