Assembly or ....

Herman Rubin cik at l.cc.purdue.edu
Fri Dec 2 23:58:33 AEST 1988


In article <787 at quintus.UUCP>, ok at quintus.uucp (Richard A. O'Keefe) writes:
> In article <21440 at apple.Apple.COM> desnoyer at Apple.COM (Peter Desnoyers) writes:
> >In article <1034 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:

		.............................

> Wrong.  The important thing is that the remainder is
> 	remainder = a - b*INT(a/b)
> I am sure that the IEEE floating-point committee would be interested to
> learn that it is not a "natural divide-type operation"; this is
> precisely the IEEE drem(a,b) function.  Quoting the SunOS manual:
> 	drem(x, y) returns the remainder r := x - n*y where n is the
> 	integer nearest the exact value of x/y; moreover if |n-x/y|=1/2
> 	then n is even.  Consequently the remainder is computed exactly
> 	and |r| <= |y|/2.  ... drem(x, 0) returns a NaN.
> 
> This is obviously a range reduction operator.  Oddly enough, on most
> present-day machines, there is a good excuse for _not_ returning the
> quotient (n) as well:  with 64-bit floats and 32-bit integers there
> is no reason to expect n to be representable as a machine "integer".
> Both results would have to be floats.  And in its use as a range
> reduction operation, you normally aren't interested in n.

I disagree.  In the varied situations I have wanted this, one of the 
following happens.

	I know the result is small, so that sometimes even 8 bits is enough.

	I only care about the last few bits.

	I want an overflow trap if it is too large.

BTW, I think there should be alternatives about the range of the remainder.
There are situations in which I want the remainder forced positive.  This is
much cheaper in hardware than in software.

Thus we have several instructions wanted, or one can look at it as one instruc-
tion with a "tag field."  Either way, it should be done.  And the integer is
wanted in many situations.
-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907
Phone: (317)494-6054
hrubin at l.cc.purdue.edu (Internet, bitnet, UUCP)



More information about the Comp.lang.c mailing list