delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/04/23/16:24:28.1

Date: Tue, 22 Apr 2003 08:45:35 -0500
From: Eric Rudd <rudd AT cyberoptics DOT com>
Subject: Re: Bug 00314 -- div() still broken
In-reply-to: <fA9pa.20115$1s1.299825@newsfeeds.bigpond.com>
Cc: djgpp-workers AT delorie DOT com
Message-id: <3EA5477F.2020901@cyberoptics.com>
Organization: CyberOptics
MIME-version: 1.0
X-Accept-Language: en,pdf
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3) Gecko/20030312
Newsgroups: comp.os.msdos.djgpp
References: <fA9pa.20115$1s1 DOT 299825 AT newsfeeds DOT bigpond DOT com>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Ben Peddell wrote:

> From your crash, it looks like the divide was being called something 
> like:
> result = div(-3,-3); 

Those args shouldn't even cause it to bomb.  I think I had some problem 
with -fomit-frame-pointer, but I'm still investigating.

> And the results:
>
> Linux div(40,-3) = -13, 1
> Asm   div(40,-3) = -13, 1
> C     div(40,-3) = -13, 1
> DJGPP div(40,-3) = -13, -1 

According to C99:

   6.5.5  Multiplicative operators

   [#6] When integers are divided, the result of the / operator
   is  the  algebraic  quotient  with   any   fractional   part
   discarded.78)   If  the  quotient  a/b is representable, the
   expression (a/b)*b + a%b shall equal a.

...so the 2.03 DJGPP div() is incorrect, since (-13)*(-3) + (-1) != 40.  
I knew this when I submitted 00314, but the log for 00314 claims that 
the bug was fixed in 2000.

> I think you can see the odd one out.
>
> By the way, the libc reference in DJGPP says that the DJGPP result is 
> correct.

OK, so we have a bug in the docs as well.

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019