integer-gmp-1.0.2.0: Integer library based on GMP

Copyright(c) Herbert Valerio Riedel 2014
LicenseBSD3
Maintainer[email protected]
Stabilityprovisional
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell2010

GHC.Integer

Contents

Description

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.

Synopsis

Documentation

data Integer Source #

Invariant: Jn# and Jp# are used iff value doesn't fit in S#

Useful properties resulting from the invariants:

Instances
Eq Integer Source # 
Instance details

Defined in GHC.Integer.Type

Methods

(==) :: Integer -> Integer -> Bool

(/=) :: Integer -> Integer -> Bool

Ord Integer Source # 
Instance details

Defined in GHC.Integer.Type

Construct Integers

mkInteger Source #

Arguments

:: Bool

sign of integer (True if non-negative)

-> [Int]

absolute value expressed in 31 bit chunks, least significant first (ideally these would be machine-word Words rather than 31-bit truncated Ints)

-> Integer 

Construct Integer value from list of Ints.

This function is used by GHC for constructing Integer literals.

smallInteger :: Int# -> Integer Source #

Should rather be called intToInteger

Conversion to other integral types

integerToInt :: Integer -> Int# Source #

Truncates Integer to least-significant Int#

Helpers for RealFloat type-class operations

Arithmetic operations

minusInteger :: Integer -> Integer -> Integer Source #

Subtract one Integer from another.

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.

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.

Comparison predicates

neqInteger :: Integer -> Integer -> Bool Source #

Not-equal predicate.

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

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.

Hashing