[GHC] #14085: powModInteger sometimes ignores sign of argument
GHC
ghc-devs at haskell.org
Thu Aug 3 13:31:32 UTC 2017
#14085: powModInteger sometimes ignores sign of argument
-------------------------------------+-------------------------------------
Reporter: ocheron | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Core | Version: 8.2.1
Libraries |
Keywords: integer-gmp | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Function `intToSBigNat#` returns a `PosBN` result when input is < -1, but
it should be `NegBN` instead.
As a consequence functions like `powModInteger` give incorrect result for
small negative numbers:
{{{
$ ghci
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
> :m GHC.Integer.GMP.Internals
> powModInteger (-2) 3 123
8
> (-2)^3 `mod` 123
115
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14085>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list