Xref: utzoo comp.lang.c++:2158 comp.lang.c:14438 comp.lang.forth:697 comp.lang.fortran:1565 comp.lang.misc:2240 comp.arch:7397
Path: utzoo!utgpu!watmath!clyde!att!rutgers!mailrus!ames!sgi!arisia!quintus!ok
From: ok@quintus.uucp (Richard A. O'Keefe)
Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc,comp.arch
Subject: Re: Assembly or ....
Message-ID: <787@quintus.UUCP>
Date: 1 Dec 88 06:41:07 GMT
References: <1388@aucs.UUCP| <729@convex.UUCP> <1961@crete.cs.glasgow.ac.uk> <949@taux01.UUCP> <1034@l.cc.purdue.edu> <21440@apple.Apple.COM>
Sender: news@quintus.UUCP
Reply-To: ok@quintus.UUCP (Richard A. O'Keefe)
Organization: Quintus Computer Systems, Inc.
Lines: 25

In article <21440@apple.Apple.COM> desnoyer@Apple.COM (Peter Desnoyers) writes:
>In article <1034@l.cc.purdue.edu> cik@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.