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

Attachment: msg04898/pgp00000.pgp
Description: PGP signature

Reply via email to