diff options
author | Olivier Chéron <olivier.cheron@gmail.com> | 2017-08-17 10:32:28 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-08-17 16:42:55 -0400 |
commit | c5605ae00e9bff90db7a5f24ff3b8de2aba3b55b (patch) | |
tree | 8d40fce633ea361a369c6acbe14bbc73bb943e5f /libraries/integer-gmp/src | |
parent | 038534755b1040470453e82531d698a952d4dd05 (diff) | |
download | haskell-c5605ae00e9bff90db7a5f24ff3b8de2aba3b55b.tar.gz |
Make function intToSBigNat# preserve sign (fixes #14085)
Impacts only functions gcdExtInteger, powModInteger and
recipModInteger which gave invalid results on negative S# inputs.
Also fixes gcdExtInteger assertion when first argument is negative.
Test Plan: Updated test case integerGmpInternals
Reviewers: austin, hvr, goldfire, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #14085
Differential Revision: https://phabricator.haskell.org/D3826
Diffstat (limited to 'libraries/integer-gmp/src')
-rw-r--r-- | libraries/integer-gmp/src/GHC/Integer/Type.hs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libraries/integer-gmp/src/GHC/Integer/Type.hs b/libraries/integer-gmp/src/GHC/Integer/Type.hs index d5f92b32db..952ff6d3e9 100644 --- a/libraries/integer-gmp/src/GHC/Integer/Type.hs +++ b/libraries/integer-gmp/src/GHC/Integer/Type.hs @@ -1996,7 +1996,7 @@ intToSBigNat# 0# = PosBN zeroBigNat intToSBigNat# 1# = PosBN oneBigNat intToSBigNat# (-1#) = NegBN oneBigNat intToSBigNat# i# | isTrue# (i# ># 0#) = PosBN (wordToBigNat (int2Word# i#)) - | True = PosBN (wordToBigNat (int2Word# (negateInt# i#))) + | True = NegBN (wordToBigNat (int2Word# (negateInt# i#))) -- | Convert 'Integer' into 'SBigNat' integerToSBigNat :: Integer -> SBigNat |