Article View: comp.sys.atari.st
Article #27221Re: MWC problem with 'long int'
From: mrd
Date: Wed, 17 Jun 1987 02:49
Date: Wed, 17 Jun 1987 02:49
39 lines
2143 bytes
2143 bytes
>From: ubc-vision!alberta!sask!long@beaver.cs.washington.edu (Warren Long)
>
>I have been porting some programs written to run on a SUN system to
>my atari with MWC v.2. I have discovered that:
>
>long int temp1;
>int m;
>------
>m= anything....;
>temp1 += m;
>-------
>always leaves temp1 = 0;
>and ended up with the same results. Is this an illegal thing to do??
>I assumed that types would be coersed into the correct thing. This
>works fine on SUN, ULTRIX and UNIX.
(First off I do not own MWC. (yet))
This operation is not legal. In general it is usually advised that you
do ALL type coersions in c. To quote KR page 184 section 6.6
"if either operand is long ... that is the type of the result"
Therefor you are assigning a long to an int.
On most large systems this is not a problem as both int and long
ints are 32 bits so you get away with it. I assume that MWC ints are 16
bits. (I may be wrong about MWC ints but it doesn't matter) This can
and will cause problems. If you have a unix box handy run lint on the
programs. lint will complain. If you fix up the code so that lint
doesn't complain, you should not have any problems. If you don't have
lint see if MWC can be forced to complain when compiling the program;
many of the new compilers for micros have a sort of lint built in (like
turboc).
MWC is not to be blamed for doing this, it is following KR faithfully
at least on this point.
Michael DeCorte
mrd@clutx.clarkson.edu
mrd@clutx.bitnet
p.s. KR stands for Kernighan and Ritchie "The C Programming Language" of
course.
Technical Details
Message-ID:
<8706170249.AA17938@clutx.clarkson.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!clutx.BITNET!mrdShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!clutx.BITNET!mrd From: mrd@clutx.BITNET.UUCP Newsgroups: comp.sys.atari.st Subject: Re: MWC problem with 'long int' Message-ID: <8706170249.AA17938@clutx.clarkson.edu> Date: Tue, 16-Jun-87 22:49:21 EDT Article-I.D.: clutx.8706170249.AA17938 Posted: Tue Jun 16 22:49:21 1987 Date-Received: Thu, 18-Jun-87 05:07:26 EDT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 39