Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ll-xn!husc6!bbn!rochester!PT.CS.CMU.EDU!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.c,comp.misc Subject: Re: 32bit = 16bit x 16bit (Really: Compiler deficiencies) Message-ID: <2998@aw.sei.cmu.edu> Date: Mon, 26-Oct-87 17:24:05 EST Article-I.D.: aw.2998 Posted: Mon Oct 26 17:24:05 1987 Date-Received: Thu, 29-Oct-87 04:43:29 EST References: <141@kesmai.COM> <7349@alice.UUCP> <146MAXHAM@RICE> <593@l.cc.purdue.edu> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (PUT YOUR NAME HERE) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 19 Xref: mnetor comp.lang.c:5158 comp.misc:1535 In article <593@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: [discussion of 16*16=>32] >A general problem with HLL's is that they do not have the necessary >flexibility to handle situations like this. 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. The language RTL/2 has exactly this feature; it has versions of "*" that can multiply integers to give long ints or fractions to give long fracs. A more modern language that recognises this problem is Ada, which has explicit features for fixed-point multiplication with double-length result (hidden in RM 3.5.9,3.5.10), and indeed for "rule-of-three" operations (multiply to double length; divide back to single length). These are defined in fairly general terms, and so can be mapped onto a variety of multiple-length machine types, not just 16 and 32. The systems language BCPL has an extension that provides the rule-of-three primitive (called MULDIV), but for integers only.