diff options
author | Gabor Greif <ggreif@gmail.com> | 2012-07-24 14:31:36 +0200 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2012-07-24 14:31:36 +0200 |
commit | 9f0eca5a93e5b07811274629f2844a60515cbcbd (patch) | |
tree | 73d972b856e80dbc6ed653694a0f25a1b1a5c501 /libraries/integer-simple | |
parent | 72ec1df20e0bda9d76856516a9edc274a638d0fb (diff) | |
download | haskell-9f0eca5a93e5b07811274629f2844a60515cbcbd.tar.gz |
track integer-gmp and add 'divInteger', 'modInteger'
Diffstat (limited to 'libraries/integer-simple')
-rw-r--r-- | libraries/integer-simple/GHC/Integer.hs | 3 | ||||
-rw-r--r-- | libraries/integer-simple/GHC/Integer/Type.hs | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libraries/integer-simple/GHC/Integer.hs b/libraries/integer-simple/GHC/Integer.hs index c9b50a7cf5..4122d382fd 100644 --- a/libraries/integer-simple/GHC/Integer.hs +++ b/libraries/integer-simple/GHC/Integer.hs @@ -4,7 +4,7 @@ ----------------------------------------------------------------------------- -- | -- Module : GHC.Integer --- Copyright : (c) Ian Lynagh 2007-2008 +-- Copyright : (c) Ian Lynagh 2007-2012 -- License : BSD3 -- -- Maintainer : igloo@earth.li @@ -27,6 +27,7 @@ module GHC.Integer ( plusInteger, minusInteger, timesInteger, negateInteger, eqInteger, neqInteger, absInteger, signumInteger, leInteger, gtInteger, ltInteger, geInteger, compareInteger, + divInteger, modInteger, divModInteger, quotRemInteger, quotInteger, remInteger, encodeFloatInteger, decodeFloatInteger, floatFromInteger, encodeDoubleInteger, decodeDoubleInteger, doubleFromInteger, diff --git a/libraries/integer-simple/GHC/Integer/Type.hs b/libraries/integer-simple/GHC/Integer/Type.hs index c3d812c1fe..67ed19c6bb 100644 --- a/libraries/integer-simple/GHC/Integer/Type.hs +++ b/libraries/integer-simple/GHC/Integer/Type.hs @@ -7,7 +7,7 @@ ----------------------------------------------------------------------------- -- | -- Module : GHC.Integer.Type --- Copyright : (c) Ian Lynagh 2007-2008 +-- Copyright : (c) Ian Lynagh 2007-2012 -- License : BSD3 -- -- Maintainer : igloo@earth.li @@ -370,6 +370,16 @@ n `divModInteger` d = then (# q `minusInteger` oneInteger, r `plusInteger` d #) else (# q, r #) +{-# NOINLINE divInteger #-} +divInteger :: Integer -> Integer -> Integer +n `divInteger` d = quotient + where (# quotient, _ #) = n `divModInteger` d + +{-# NOINLINE modInteger #-} +modInteger :: Integer -> Integer -> Integer +n `modInteger` d = modulus + where (# _, modulus #) = n `divModInteger` d + {-# NOINLINE quotRemInteger #-} quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) Naught `quotRemInteger` (!_) = (# Naught, Naught #) |