Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!sri-spam!mordor!lll-tis!ptsfa!hoptoad!academ!killer!codas!ge-dab!ge-rtp!edison!uvacs!virginia!kesmai!dca From: dca@kesmai.COM (David C. Albrecht) Newsgroups: comp.lang.c,comp.sys.atari.st,comp.sys.amiga Subject: 32bit = 16bit x 16bit Message-ID: <141@kesmai.COM> Date: Tue, 29-Sep-87 13:27:40 EDT Article-I.D.: kesmai.141 Posted: Tue Sep 29 13:27:40 1987 Date-Received: Tue, 13-Oct-87 06:13:37 EDT Organization: Kesmai Corporation, Charlottesville, VA Lines: 40 Xref: mnetor comp.lang.c:4847 comp.sys.atari.st:5641 comp.sys.amiga:9303 I would be interested in some other people's input on this. One of our latest products where I work is a flight simulator. We do alot of integer arithmetic. The original target of the program was the MAC it has since been ported to the Amiga and is now being ported to the ST. Okay, note that these are all 68K machines. In trying to squeeze more speed out of it on the Amiga I noticed a good many multiplys were 16x16=32 (which is supported in hardware on the 68000) while it was currently using 32x32=32 (which is not). In attempting to get the MULS operation I made the variables 16bit in size and coded the expression thusly: ((long) (x * y)) It is a bit greasy but it was the only way I could think of to get the proper result. On the Amiga using Lattice 3.10 it worked ducky. Recently we moved the code back to the MAC which is using Counsulair (sp?) and that also seems to work. On the ST using Mark Williams we were not so lucky. They actually explicitly sign extend the result throwing away the upper 16bits. We assumed that they did so because their compiler was not smart enough to recognize that it already had a long result which it could just use. After some communication with them they claimed that the phrase on pg184 in K&R which says that an expression with two ints should produce an int (their ints are 16 bits) REQUIRE that they sign extend or they will fail some of their commercial customers acceptance suites. Personally I think they are full of it. Does anyone know of a commercial test suite that checks to make sure that y = x * x where x is a 16 bit int and y is long (32 bits) produces garbage instead of the proper result? Seems like just the kind of thing I would want in my software. Why have good numbers when I could have garbage? Seriously, I can understand their compiler being a little simple and not producing the result I desire because it isn't sharp enough to realise that the result of a MULS is either 16 bits or 32 bits depending on what you want. I find it extremely unlikely that this behavior is required, however. If someone out there could point out to me the error of my ways and why an acceptance suite would test this or just relate first hand experience with a suite that does test this I would be most interested. David Albrecht