Assembly or ....
Richard A. O'Keefe
ok at quintus.uucp
Thu Dec 1 16:41:07 AEST 1988
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:
>>[about the iq, r := x div y, x mod y instruction]
>The operation mentioned was either poorly defined, or merely consisted of:
> convert a, b to int
> div a,b -> int quotient, remainder
> convert remainder to float
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.
More information about the Comp.lang.c
mailing list