crowl@cs.rochester.edu (Lawrence Crowl) (06/27/89)
In article <22218@winchester.mips.COM> mash@mips.COM (John Mashey) 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. 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. There are not a lot of languages currently that support such arithmetic, but newer languages are more likely to. 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. Fixed point is generally not used much because most languages do not support it. -- Lawrence Crowl 716-275-9499 University of Rochester crowl@cs.rochester.edu Computer Science Department ...!{allegra,decvax,rutgers}!rochester!crowl Rochester, New York, 14627
bartho@obs.unige.ch (PAUL BARTHOLDI) (06/30/89)
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