Article View: net.micro.atari16
Article #391problem with C modulo operator using Developers Kit
From: Ron Janzen
Date: Wed, 16 Apr 1986 00:48
Date: Wed, 16 Apr 1986 00:48
30 lines
1805 bytes
1805 bytes
There is a problem in the Atari Developer's Kit when using the
C modulo operator (%) when both operands are longs. The problem
appears in the following way. Consider this short program,
#include <stdio.h>
main()
{
long i;
for ( i = 0; i < 10; i++ )
printf( "i = %ld, i %% 3 = %ld\n", i, i % 3L );
}
If you compile this and link it with gemlib it will work as expected.
However if you link it with vdibind and gemlib (as you would in a
program that uses VDI routines) in that order, the result of the i % 3L
operation is garbage. We traced it down to the fact that both vdibind
and gemlib contain the lrem function which is used when finding the
modulo of two longs. Evidently the one in vdibind is buggy whereas the
one in gemlib works. Therefore when we linked with vdibind before
gemlib the buggy version was linked in. It seems to me that vdibind
shouldn't even contain this routine (it also contains lmul.o and
ldiv.o). These routines should be (and are) in the C runtime library
(gemlib). We just took them out of vdibind and everything works OK now.
Is there some reason these routines were in vdibind?
--
Ron Janzen
Ontario Science Centre, Toronto
...!{allegra,ihnp4,linus,decvax}!utzoo!oscvax!ron
Technical Details
Message-ID:
<402@oscvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utcs!oscvax!ronShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site oscvax.UUCP Path: arc1-ca.pugleaf.net!utzoo!utcs!oscvax!ron From: ron@oscvax.UUCP (Ron Janzen) Newsgroups: net.micro.atari16 Subject: problem with C modulo operator using Developers Kit Message-ID: <402@oscvax.UUCP> Date: Tue, 15-Apr-86 19:48:18 EST Article-I.D.: oscvax.402 Posted: Tue Apr 15 19:48:18 1986 Date-Received: Tue, 15-Apr-86 20:11:56 EST Reply-To: ron@oscvax.UUCP (Ron Janzen) Organization: Ontario Science Centre, Toronto Lines: 30