GHC.Integer

base-4.16.0.0: Basic libraries

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Integer

Contents

- Construct `Integer`s
- Conversion to other integral types
- Helpers for `RealFloat` type-class operations
- Arithmetic operations
- Comparison predicates
  - `Int#`-boolean valued versions of comparison predicates
- Bit-operations
- Hashing

Description

Compatibility module for pre ghc-bignum code.

Synopsis

- data Integer
- smallInteger :: Int# -> Integer
- wordToInteger :: Word# -> Integer
- integerToWord :: Integer -> Word#
- integerToInt :: Integer -> Int#
- encodeFloatInteger :: Integer -> Int# -> Float#
- encodeDoubleInteger :: Integer -> Int# -> Double#
- decodeDoubleInteger :: Double# -> (# Integer, Int# #)
- 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
- popCountInteger :: Integer -> Int#
- bitInteger :: Int# -> Integer
- hashInteger :: Integer -> Int#

# Documentation

data Integer Source #

Arbitrary precision integers. In contrast with fixed-size integral types such as `Int`, the `Integer` type represents the entire infinite range of integers.

Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.

If the value is small (fit into an `Int`), `IS` constructor is used. Otherwise `Integer` and `IN` constructors are used to store a `BigNat` representing respectively the positive or the negative value magnitude.

Invariant: `Integer` and `IN` are used iff value doesn't fit in `IS`

#### Instances

Instances details

Data Integer # | Since: base-4.0.0.0
Instance details Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Integer -> c Integer Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Integer Source # toConstr :: Integer -> Constr Source # dataTypeOf :: Integer -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Integer) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Integer) Source # gmapT :: (forall b. Data b => b -> b) -> Integer -> Integer Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Integer -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Integer -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Integer -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Integer -> m Integer Source #
Bits Integer # | Since: base-2.1
Instance details Defined in GHC.Bits Methods (.&.) :: Integer -> Integer -> Integer Source # (.|.) :: Integer -> Integer -> Integer Source # xor :: Integer -> Integer -> Integer Source # complement :: Integer -> Integer Source # shift :: Integer -> Int -> Integer Source # rotate :: Integer -> Int -> Integer Source # zeroBits :: Integer Source # bit :: Int -> Integer Source # setBit :: Integer -> Int -> Integer Source # clearBit :: Integer -> Int -> Integer Source # complementBit :: Integer -> Int -> Integer Source # testBit :: Integer -> Int -> Bool Source # bitSizeMaybe :: Integer -> Maybe Int Source # bitSize :: Integer -> Int Source # isSigned :: Integer -> Bool Source # shiftL :: Integer -> Int -> Integer Source # unsafeShiftL :: Integer -> Int -> Integer Source # shiftR :: Integer -> Int -> Integer Source # unsafeShiftR :: Integer -> Int -> Integer Source # rotateL :: Integer -> Int -> Integer Source # rotateR :: Integer -> Int -> Integer Source # popCount :: Integer -> Int Source #
Enum Integer # | Since: base-2.1
Instance details Defined in GHC.Enum Methods succ :: Integer -> Integer Source # pred :: Integer -> Integer Source # toEnum :: Int -> Integer Source # fromEnum :: Integer -> Int Source # enumFrom :: Integer -> [Integer] Source # enumFromThen :: Integer -> Integer -> [Integer] Source # enumFromTo :: Integer -> Integer -> [Integer] Source # enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] Source #
Ix Integer # | Since: base-2.1
Instance details Defined in GHC.Ix Methods range :: (Integer, Integer) -> [Integer] Source # index :: (Integer, Integer) -> Integer -> Int Source # unsafeIndex :: (Integer, Integer) -> Integer -> Int Source # inRange :: (Integer, Integer) -> Integer -> Bool Source # rangeSize :: (Integer, Integer) -> Int Source # unsafeRangeSize :: (Integer, Integer) -> Int Source #
Num Integer # | Since: base-2.1
Instance details Defined in GHC.Num Methods (+) :: Integer -> Integer -> Integer Source # (-) :: Integer -> Integer -> Integer Source # (*) :: Integer -> Integer -> Integer Source # negate :: Integer -> Integer Source # abs :: Integer -> Integer Source # signum :: Integer -> Integer Source # fromInteger :: Integer -> Integer Source #
Read Integer # | Since: base-2.1
Instance details Defined in GHC.Read Methods readsPrec :: Int -> ReadS Integer Source # readList :: ReadS [Integer] Source # readPrec :: ReadPrec Integer Source # readListPrec :: ReadPrec [Integer] Source #
Integral Integer # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods quot :: Integer -> Integer -> Integer Source # rem :: Integer -> Integer -> Integer Source # div :: Integer -> Integer -> Integer Source # mod :: Integer -> Integer -> Integer Source # quotRem :: Integer -> Integer -> (Integer, Integer) Source # divMod :: Integer -> Integer -> (Integer, Integer) Source # toInteger :: Integer -> Integer Source #
Real Integer # | Since: base-2.0.1
Instance details Defined in GHC.Real Methods toRational :: Integer -> Rational Source #
Show Integer # | Since: base-2.1
Instance details Defined in GHC.Show Methods showsPrec :: Int -> Integer -> ShowS Source # show :: Integer -> String Source # showList :: [Integer] -> ShowS Source #
PrintfArg Integer # | Since: base-2.1
Instance details Defined in Text.Printf Methods formatArg :: Integer -> FieldFormatter Source # parseFormat :: Integer -> ModifierParser Source #
Eq Integer |
Instance details Defined in GHC.Num.Integer Methods (==) :: Integer -> Integer -> Bool Source # (/=) :: Integer -> Integer -> Bool Source #
Ord Integer |
Instance details Defined in GHC.Num.Integer Methods compare :: Integer -> Integer -> Ordering Source # (<) :: Integer -> Integer -> Bool Source # (<=) :: Integer -> Integer -> Bool Source # (>) :: Integer -> Integer -> Bool Source # (>=) :: Integer -> Integer -> Bool Source # max :: Integer -> Integer -> Integer Source # min :: Integer -> Integer -> Integer Source #

# Construct `Integer`s

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 #

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

decodeDoubleInteger :: Double# -> (# Integer, Int# #) 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 #

## `Int#`-boolean valued versions of comparison predicates

These operations return `0#` and `1#` instead of `False` and `True` respectively. See PrimBool wiki-page for more details

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

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

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

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

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

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

# 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 #

popCountInteger :: Integer -> Int# Source #

bitInteger :: Int# -> Integer Source #

# Hashing

hashInteger :: Integer -> Int# Source #