Xref: utzoo comp.lang.c++:2173 comp.lang.c:14479 comp.lang.forth:711 comp.lang.fortran:1578 comp.lang.misc:2263 comp.arch:7421 Path: utzoo!utgpu!watmath!clyde!att!rutgers!mailrus!purdue!i.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc,comp.arch Subject: Re: Assembly or .... Summary: The user should be able to specify Message-ID: <1041@l.cc.purdue.edu> Date: 2 Dec 88 13:58:33 GMT References: <1388@aucs.UUCP| <729@convex.UUCP> <1961@crete.cs.glasgow.ac.uk> <787@quintus.UUCP> Organization: Purdue University Statistics Department Lines: 43 In article <787@quintus.UUCP>, ok@quintus.uucp (Richard A. O'Keefe) writes: > 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: ............................. > 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@l.cc.purdue.edu (Internet, bitnet, UUCP)