diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-02-02 12:18:20 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-02-02 12:49:58 +0100 |
commit | bcd38ea7f97cc3a3ed192bc0666c816c027bd9fc (patch) | |
tree | 521903b37368f4d7b1c58d4ed355eafd40f06dd6 /libraries/integer-gmp/aclocal.m4 | |
parent | c7a050f1ca2df732f7310c1fa0b9c4963b89017e (diff) | |
download | haskell-bcd38ea7f97cc3a3ed192bc0666c816c027bd9fc.tar.gz |
Fix negation of `divMod`/`quotRem` results (fixes #8726)
High-level pseudo code of what the code was supposed to implement:
quotRem' :: Integer -> Integer -> (Integer,Integer)
quotRem' a b@(S# _)
| b < 0 = negFst . uncurry quotRem' . negSnd $ (a,b)
| otherwise = quotRemUI a (fromIntegral (abs b))
divMod' :: Integer -> Integer -> (Integer,Integer)
divMod' a b@(S# _)
| b < 0 = negSnd . uncurry divMod' . negBoth $ (a,b)
| otherwise = divModUI a (fromIntegral b)
negFst (q,r) = (-q,r)
negSnd (q,r) = ( q,-r)
negBoth (q,r) = (-q,-r)
-- quotRemUI and divModUI represent GMP's `mpz_{f,t}div_qr_ui()`
quotRemUI, divModUI :: Integer -> Word -> (Integer,Integer)
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Diffstat (limited to 'libraries/integer-gmp/aclocal.m4')
0 files changed, 0 insertions, 0 deletions