Xref: utzoo comp.arch:10492 misc.wanted:5447 comp.sources.wanted:7960 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!cernvax!cui!ugun2b!ugobs!bartho From: bartho@obs.unige.ch (PAUL BARTHOLDI) Newsgroups: comp.arch,misc.wanted,comp.sources.wanted Subject: Re: Double Width Integer Multiplication and Division Message-ID: <255@obs.unige.ch> Date: 30 Jun 89 09:17:14 GMT References: <57125@linus.UUCP> <1989Jun24.230056.27774@utzoo.uucp> <22218@winchester.mips.COM> <1989Jun26.195044.4197@cs.rochester.edu> Organization: University of Geneva, Switzerland Lines: 40 In article <1989Jun26.195044.4197@cs.rochester.edu>, crowl@cs.rochester.edu (Lawrence Crowl) writes: >>When we were [designing integer division support on the MIPS processors], we >>couldn't think of any languages whose natural implementation on a 32-bit >>machine would expect generation of a 64 by 32 bit divide as the expected >>operation. Does anybody know of any such, or is this strictly something one >>would use in handcoded routines? > > Languages which support fixed-point arithmetic, e.g. PL/I and Ada, could use > such a feature to substantially improve fixed-point performance ... FORTH is the only language to my knowledge that use explicitely integer double precision intermediate for multiplication/division/modulo. The original and standard forth have 16 bits integers, so double are 32 bits. The point is that, as soon you do integer arithmetic, you need to (re)scale your operands, specialy during multiplication/division. So, most of time, a multiplication is immediately followed by a division, or a division preceded by a multiplication, and a double precision intermediate results means you do not loose precision. For example, suppose you want to multiply a number by 'pi'. You would then multiply this number by 31415 and divide the result by 10000 (16 bits) or by 314159265 and 100000000 ... Notice that the high level operator has now three operands and should be called 'ternary'. This is exactely what forth does. forth use reverse polish notation, which is very nice for ternary operators : a b c */ ('*/" is the operator) means take the product of a and b in double precision, and divide it immediately by c, getting a single precision integer as result. you can have *mod that would leave a*b mod c or even */mod that will leave both quotient and modulo of a*b by c. all these operators have been extremely usefull in process control, data acquisition etc, in particular with small computer or micro without FPA. for more information about forth, see : MG Kelly and N Spies : FORTH: a text and reference , Prentice-Hall 1986 L Brodie : Starting FORTH, Prentice-HAll 1982 L Brodie : Thinking FORTH, Prentice-Hall 1984 regards, Paul Bartholdi Dr Paul Bartholdi bartho@cgeuge54.bitnet Observatoire de Geneve bartho@obs.unige.ch CH-1290 Sauverny 02284682161350::bartho (psi) Switzerland 20579::ugobs::bartho