Copyright | (c) Herbert Valerio Riedel 2014 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | provisional |
Portability | non-portable (GHC Extensions) |
Safe Haskell | None |
Language | Haskell2010 |
The Integer
type.
This module exposes the portable Integer
API. See GHC.Integer.GMP.Internals for the integer-gmp
-specific internal representation of Integer
as well as optimized GMP-specific operations.
Invariant: Jn#
and Jp#
are used iff value doesn't fit in S#
Useful properties resulting from the invariants:
:: Bool | sign of integer ( |
-> [Int] | absolute value expressed in 31 bit chunks, least significant first (ideally these would be machine-word |
-> Integer |
Construct Integer
value from list of Int
s.
This function is used by GHC for constructing Integer
literals.
smallInteger :: Int# -> Integer Source
Should rather be called intToInteger
wordToInteger :: Word# -> Integer Source
integerToWord :: Integer -> Word# Source
integerToInt :: Integer -> Int# Source
Truncates Integer
to least-significant Int#
encodeFloatInteger :: Integer -> Int# -> Float# Source
floatFromInteger :: Integer -> Float# Source
encodeDoubleInteger :: Integer -> Int# -> Double# Source
decodeDoubleInteger :: Double# -> (#Integer, Int##) Source
doubleFromInteger :: Integer -> Double# Source
plusInteger :: Integer -> Integer -> Integer Source
Add two Integer
s
minusInteger :: Integer -> Integer -> Integer Source
Subtract one Integer
from another.
timesInteger :: Integer -> Integer -> Integer Source
Multiply two Integer
s
negateInteger :: Integer -> Integer Source
Negate Integer
absInteger :: Integer -> Integer Source
Compute absolute value of an Integer
signumInteger :: Integer -> Integer Source
Return -1
, 0
, and 1
depending on whether argument is negative, zero, or positive, respectively
divModInteger :: Integer -> Integer -> (#Integer, Integer#) Source
Simultaneous divInteger
and modInteger
.
Divisor must be non-zero otherwise the GHC runtime will terminate with a division-by-zero fault.
divInteger :: Integer -> Integer -> Integer Source
modInteger :: Integer -> Integer -> Integer Source
quotRemInteger :: Integer -> Integer -> (#Integer, Integer#) Source
Simultaneous quotInteger
and remInteger
.
Divisor must be non-zero otherwise the GHC runtime will terminate with a division-by-zero fault.
quotInteger :: Integer -> Integer -> Integer Source
remInteger :: Integer -> Integer -> Integer Source
eqInteger :: Integer -> Integer -> Bool Source
neqInteger :: Integer -> Integer -> Bool Source
Not-equal predicate.
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 predicatesThese 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
andInteger :: Integer -> Integer -> Integer Source
Bitwise AND operation
orInteger :: Integer -> Integer -> Integer Source
Bitwise OR operation
xorInteger :: Integer -> Integer -> Integer Source
Bitwise XOR operation
complementInteger :: Integer -> Integer Source
Bitwise NOT
operation
shiftLInteger :: Integer -> Int# -> Integer Source
Shift-left operation
Even though the shift-amount is expressed as Int#
, the result is undefined for negative shift-amounts.
shiftRInteger :: Integer -> Int# -> Integer Source
Arithmetic shift-right operation
Even though the shift-amount is expressed as Int#
, the result is undefined for negative shift-amounts.
testBitInteger :: Integer -> Int# -> Bool Source
Test if n-th bit is set.
hashInteger :: Integer -> Int# Source
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/integer-gmp-1.0.1.0/GHC-Integer.html