Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!claris!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW Pascal Bug? Or am I wrong. Message-ID: <12528@apple.Apple.COM> Date: 20 Jun 88 18:55:45 GMT References: <3203@polyslo.UUCP> Reply-To: lsr@apple.apple.com.UUCP (Larry Rosenstein) Organization: Advanced Technology Group, Apple Computer Lines: 29 In article <3203@polyslo.UUCP> dorourke@polyslo.UUCP (David O'Rourke) writes: > >the wrong result, usually negative, in Z even though Z is a LONGINT. Now is >this what the compiler is suppose to do, or is it suppose to convert to the >LONGINT. The compiler is oprating correctly. If you turn on overflow checking, then you would get a runtime exception. The reason that overflow checking is not on all the time is that it expands the resulting code enormously. One workaround is to coerce one value to a LONGINT so that the compiler uses 32-bit multiplication. The only problem with that is that the multiplication requires a library routine, since the 68000 doesn't have a 32-bit multiply. A really nifty solution (used in MacApp) is to define the following function: FUNCTION IntMultiply(x,y: INTEGER): LONGINT; INLINE $301F, $C1DF, $2E80; This takes the 2 integers and multiplies them using the 68000 multiply instruction, yielding a longint. It doesn't require a call to the Pascal library, and is relatively fast. -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 27-AJ Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr