diff options
author | Bodigrim <andrew.lelechenko@gmail.com> | 2018-07-07 00:20:10 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-07-12 11:25:47 -0400 |
commit | 7c207c86ab0de955ebec70eeeb366ba0d94acc4a (patch) | |
tree | af59dd70479650062617d90391caa52d18b92cb2 /libraries/integer-gmp | |
parent | 19e1e6bf22031d563eb7f0a3d09bd07fce9e04d7 (diff) | |
download | haskell-7c207c86ab0de955ebec70eeeb366ba0d94acc4a.tar.gz |
Fix gcdExtInteger (trac#15350)
Diffstat (limited to 'libraries/integer-gmp')
-rw-r--r-- | libraries/integer-gmp/src/GHC/Integer/Type.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libraries/integer-gmp/src/GHC/Integer/Type.hs b/libraries/integer-gmp/src/GHC/Integer/Type.hs index 9ea7c0641c..9636b9f443 100644 --- a/libraries/integer-gmp/src/GHC/Integer/Type.hs +++ b/libraries/integer-gmp/src/GHC/Integer/Type.hs @@ -1389,7 +1389,9 @@ gcdExtSBigNat x y = case runS go of (g,s) -> (# g, s #) where go = do g@(MBN# g#) <- newBigNat# gn0# - s@(MBN# s#) <- newBigNat# (absI# xn#) + -- According to https://gmplib.org/manual/Number-Theoretic-Functions.html#index-mpz_005fgcdext + -- abs(s) < abs(y) / (2 g) + s@(MBN# s#) <- newBigNat# (absI# yn#) I# ssn_# <- liftIO (integer_gmp_gcdext# s# g# x# xn# y# yn#) let ssn# = narrowGmpSize# ssn_# sn# = absI# ssn# |