Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!ukc!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: comp.arch Subject: Re: Double Width Integer Multiplication and Division Summary: fixed point muldiv wins... Message-ID: <1035@aber-cs.UUCP> Date: 28 Jun 89 11:28:04 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 48 In article <1989Jun26.195044.4197@cs.rochester.edu> crowl@cs.rochester.edu (Lawrence Crowl) writes: Languages which support fixed-point arithmetic, e.g. PL/I and Ada, could use such a feature to substantially improve fixed-point performance. In addition, languages that support a more general notion of integers, such as Lisp bignums or declared ranges, can use them to improve the performance on integers larger than a single word. [ .... ] Such support is especially crucial for fixed-point arithmetic. Fixed-point arithmetic is often a win in both time and precision over floating point. I did a Mandelbrot program using fixed-point (via the 68020 32x32->64 multiply) that was 50% faster than using the FPA on a Sun 3/260 and 480% (5x) faster than using the 68881. However, such advantages cannot be effectively realized without language support. All true, but for language support. There is an enlightening article by Martin Richards in a a very old Sw.Pract.&Exp. issue (middle seventies I think) in which he uses a "muldiv()" function (implemented in assembler) for BCPL that multiplies two single length numbers, giving a double length result that is divided by a single length number, returning a single length result. Something like (but more efficiently): int muldiv(a,b,c) { return (int) (((long) a * (long) b)/(long) c); } This is almost enough to make fixed point comfortable in any language, however inhospitable (BCPL for example has only one length of integer). Richards describes in his paper having been able thanks to "muldiv()" to run a realistic flight simulator on a quite slow and small machine without floating point. Final remarks on the issue of RISC vs. multiplication/division: [1] You are not supposed to write assembler programs on a RISC machine. The compilers have sophisticated algorithms to generate "optimal" multiplication/division out of simpler instructions. [2] Fixed point and the "muldiv()" idea to me look very much in the RISC philosphy of minimalism. Fixed point, and multiple precision integer arithmetic, are in many many cases preferable to floating point and its complexities. Too bad that mathematicians are lulled in a false sense of familiarity by floating point's "scientific notation" and apparent support for real numbers. -- Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk