Date: Tue, 22 Apr 2003 08:45:35 -0500 From: Eric Rudd Subject: Re: Bug 00314 -- div() still broken In-reply-to: Cc: djgpp-workers AT delorie DOT com Message-id: <3EA5477F.2020901@cyberoptics.com> Organization: CyberOptics MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit 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: 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 Precedence: bulk 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