Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.c,comp.misc Subject: Re: 32bit = 16bit x 16bit (Really: Compiler deficiencies) Message-ID: <10621@think.UUCP> Date: Thu, 29-Oct-87 18:17:58 EST Article-I.D.: think.10621 Posted: Thu Oct 29 18:17:58 1987 Date-Received: Tue, 3-Nov-87 06:08:36 EST References: <141@kesmai.COM> <7349@alice.UUCP> <146MAXHAM@RICE> <593@l.cc.purdue.edu> <120@babbage.acc.virginia.edu> Sender: usenet@think.UUCP Reply-To: barmar@pozzo.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 27 Xref: mnetor comp.lang.c:5204 comp.misc:1551 In article <120@babbage.acc.virginia.edu> mac3n@babbage.acc.virginia.edu (Alex Colvin) writes: >In article <593@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: >> 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. PL/I's default is to do just this! And if you multiply "fixed bin (12,5)" (12 bits with 5 after the binary point) by "fixed bin (16,3)" the default result is "fixed bin (28,8)". Imagine -- a language that follows the rules for arithmetic that we learned in grade school! For cases where you know that the result will not be the default (usually when one of the operands is a literal, and the automatically-generated data type isn't appropriate), there is a version of the multiplication operator that lets you specify the size of the result: result = multiply (var, 3, 16, 3); which means "multiply var by 3 giving a sixteen-bit result with three bits after the binary point)." --- Barry Margolin Thinking Machines Corp. barmar@think.com seismo!think!barmar