Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!genrad!decvax!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: 32bit = 16bit x 16bit Message-ID: <8710121921.AA23591@cory.Berkeley.EDU> Date: Mon, 12-Oct-87 15:21:03 EDT Article-I.D.: cory.8710121921.AA23591 Posted: Mon Oct 12 15:21:03 1987 Date-Received: Wed, 14-Oct-87 00:49:27 EDT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 27 Aztec does this correctly by using MULS/MULU (thank the lords!)... I depend on it heavily for my graphics work as well... for speed. Lattice C isn't quite as smart... you need to put in some casts, but it still does it. Unfortunetly, most other compilers do not optimize this. If: long z; short x,y; z = (long)((short)x * (short)y); Doesn't work, there probably is no way to do it without using some assembly. BTW, the above applies to 32 bit compilers. 16 bit compilers will usually barf on it since theoretically the result of the multiplication is a short if the arguments are short and the compiler would then extend it to a long destroying the upper 16 bits. You could try the following for 16 bit compilers, but they have to be *smart*: z = (long)((long)x * (long)y); -Matt P.S. that first (long) cast is not strickly required, but some compilers are very stupid when it comes to checking the result variable type when applying optimization.