Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c,comp.misc Subject: Re: 32bit = 16bit x 16bit (Really: Compiler deficiencies) Message-ID: <8841@utzoo.UUCP> Date: Wed, 28-Oct-87 12:46:43 EST Article-I.D.: utzoo.8841 Posted: Wed Oct 28 12:46:43 1987 Date-Received: Wed, 28-Oct-87 12:46:43 EST References: <141@kesmai.COM> 7349@alice.UUCP <146MAXHAM@RICE>, <593@l.cc.purdue.edu> Organization: U of Toronto Zoology Lines: 18 > ... I do not know of any language > which has in its operation list an operation to multiply two 16 bit object > and get a 32 bit object... As has been said before, in C on a machine where shorts are 16 bits and longs 32, "(long)shortvar * (long)shortvar" does *exactly* this, assuming that the compiler is smart enough to notice that it can do the casts as part of the multiplication. With the bonus that it works, although more slowly, even if the compiler doesn't notice. > ... How about the related problem of multiplying two 32 bit objects and > getting a 64 bit object? ... Given suitable data types (some 32-bit-machine C compilers have a "long long" type for 64-bit integers), the same comment applies. -- PS/2: Yesterday's hardware today. | Henry Spencer @ U of Toronto Zoology OS/2: Yesterday's software tomorrow. | {allegra,ihnp4,decvax,utai}!utzoo!henry