Assembly or ....

Richard A. O'Keefe ok at quintus.uucp
Fri Dec 2 18:14:30 AEST 1988


In article <1032 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
> suppose we want to
>divide a by b, obtaining an integer result i and a remainder c.  I know
>of no machine with this instruction,...

Various people have listed machines with integer quotient-and-remainder
instructions.  I seldom agree with Herman Rubin, but he is quite capable
of reading an instruction set manual.  At any rate, he is better at that
than most of the repliers were at reading his message.  He was asking for
the equivalent of
	double a, b, r;
	long int i;
	r = drem(a, b);
	i = (int)( (a-r)/b );

Another poster says
>I've implementations of FORTH, by the way, where the expression
>	a b /%
>for example, divides a by b, leaving a/b and a%b on the stack.
	
Pop-2 has a//b which does much the same thing.

Common Lisp has
	(floor number divisor)
plus ceiling, truncate, and round.  All four functions return TWO
values: the quotient and the remainder.  E.g.
	(multiple-value-setq (Q R) (truncate N D))
In particular, Common Lisp's (round - -) function, if given floating-
point arguments, is the function that Rubin wants a single instruction for.
(Well, that's drem() anyway.  He might want one of the other three.)

I don't know, but I wouldn't be surprised if the Symbolics machines had
an instruction for this.



More information about the Comp.lang.c mailing list