-1796254192 `div` 357566600 == 5 ??
Dylan Thurston
dpt at lotus.bostoncoop.net
Thu Jun 27 20:53:44 EDT 2002
On Fri, Jun 28, 2002 at 12:08:51AM +0100, Alastair Reid wrote:
>
> >> Prelude> -1796254192 `div` 357566600
> >> -5
>
> > Except that the answer should be -6. This is bizarre. What do you
> > get for this one?
>
> >> Prelude> -1796254192 `divMod` 357566600
> > (5,349145408)
>
> Can you add some parentheses to these expressions so we're sure what
> we're looking at. Using Hugs I get:
>
> Prelude> (-1796254192 `divMod` 357566600) :: (Integer,Integer)
> ERROR - Unresolved overloading
> *** Type : Num (Integer,Integer) => (Integer,Integer)
> *** Expression : negate (divMod 1796254192 357566600)
>
> Prelude> (-1796254192) `divMod` 357566600
> (-6,349145408)
> Prelude> (-1796254192) `div` 357566600
> -6
> Prelude> -1796254192 `div` 357566600
> -5
Thanks for pointing this out; this seems to be another bug in ghc
5.02.2. According to the report, it seems unambiguous that, e.g.,
-5`div`2 should be -2, not -3.
The one I'm really interested in is this one:
Prelude> (-1796254192) `div` 357566600
5
The correct answer is what hugs gave, -6.
--Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-bugs/attachments/20020627/15c2f27f/attachment.bin
More information about the Glasgow-haskell-bugs
mailing list