Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
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 IP
and IN
constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
Instances
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
Arithmetic operations
plusInteger :: Integer -> Integer -> Integer Source #
Used to implement (+)
for the Num
typeclass.
This gives the sum of two integers.
Example
>>>
plusInteger 3 2
5
>>>
(+) 3 2
5
minusInteger :: Integer -> Integer -> Integer Source #
Used to implement (-)
for the Num
typeclass.
This gives the difference of two integers.
Example
>>>
minusInteger 3 2
1
>>>
(-) 3 2
1
timesInteger :: Integer -> Integer -> Integer Source #
Used to implement (*)
for the Num
typeclass.
This gives the product of two integers.
Example
>>>
timesInteger 3 2
6
>>>
(*) 3 2
6
negateInteger :: Integer -> Integer Source #
Used to implement negate
for the Num
typeclass.
This changes the sign of whatever integer is passed into it.
Example
>>>
negateInteger (-6)
6
>>>
negate (-6)
6
absInteger :: Integer -> Integer Source #
Used to implement abs
for the Num
typeclass.
This gives the absolute value of whatever integer is passed into it.
Example
>>>
absInteger (-6)
6
>>>
abs (-6)
6
signumInteger :: Integer -> Integer Source #
Used to implement signum
for the Num
typeclass.
This gives 1 for a positive integer, and -1 for a negative integer.
Example
>>>
signumInteger 5
1
>>>
signum 5
1
divModInteger :: Integer -> Integer -> (# Integer, Integer #) Source #
Used to implement divMod
for the Integral
typeclass.
This gives a tuple equivalent to
(div x y, mod x y)
Example
>>>
divModInteger 10 2
(5,0)
>>>
divMod 10 2
(5,0)
divInteger :: Integer -> Integer -> Integer Source #
Used to implement div
for the Integral
typeclass.
This performs integer division on its two parameters, truncated towards negative infinity.
Example
>>>
10 `divInteger` 2
5
>>>
10 `div` 2
modInteger :: Integer -> Integer -> Integer Source #
Used to implement mod
for the Integral
typeclass.
This performs the modulo operation, satisfying
((x `div` y) * y) + (x `mod` y) == x
Example
>>>
7 `modInteger` 3
1
>>>
7 `mod` 3
1
quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) Source #
Used to implement quotRem
for the Integral
typeclass.
This gives a tuple equivalent to
(quot x y, mod x y)
Example
>>>
quotRemInteger 10 2
(5,0)
>>>
quotRem 10 2
(5,0)
quotInteger :: Integer -> Integer -> Integer Source #
Used to implement quot
for the Integral
typeclass.
This performs integer division on its two parameters, truncated towards zero.
Example
>>>
quotInteger 10 2
5
>>>
quot 10 2
5
remInteger :: Integer -> Integer -> Integer Source #
Used to implement rem
for the Integral
typeclass.
This gives the remainder after integer division of its two parameters, satisfying
((x `quot` y) * y) + (x `rem` y) == x
Example
>>>
remInteger 3 2
1
>>>
rem 3 2
1
Comparison predicates
eqInteger :: Integer -> Integer -> Bool Source #
Used to implement (==)
for the Eq
typeclass.
Outputs True
if two integers are equal to each other.
Example
>>>
6 `eqInteger` 6
True
>>>
6 == 6
True
neqInteger :: Integer -> Integer -> Bool Source #
Used to implement (/=)
for the Eq
typeclass.
Outputs True
if two integers are not equal to each other.
Example
>>>
6 `neqInteger` 7
True
>>>
6 /= 7
True
leInteger :: Integer -> Integer -> Bool Source #
Used to implement (<=)
for the Ord
typeclass.
Outputs True
if the first argument is less than or equal to the second.
Example
>>>
3 `leInteger` 5
True
>>>
3 <= 5
True
gtInteger :: Integer -> Integer -> Bool Source #
Used to implement (>)
for the Ord
typeclass.
Outputs True
if the first argument is greater than the second.
Example
>>>
5 `gtInteger` 3
True
>>>
5 > 3
True
ltInteger :: Integer -> Integer -> Bool Source #
Used to implement (<)
for the Ord
typeclass.
Outputs True
if the first argument is less than the second.
Example
>>>
3 `ltInteger` 5
True
>>>
3 < 5
True
geInteger :: Integer -> Integer -> Bool Source #
Used to implement (>=)
for the Ord
typeclass.
Outputs True
if the first argument is greater than or equal to the second.
Example
>>>
5 `geInteger` 3
True
>>>
5 >= 3
True
compareInteger :: Integer -> Integer -> Ordering Source #
Used to implement compare
for the Integral
typeclass.
This takes two integers, and outputs whether the first is less than, equal to, or greater than the second.
Example
>>>
compareInteger 2 10
LT
>>>
compare 2 10
LT
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
Bit-operations
complementInteger :: Integer -> Integer Source #
popCountInteger :: Integer -> Int# Source #
bitInteger :: Int# -> Integer Source #
Hashing
hashInteger :: Integer -> Int# Source #