Xref: utzoo comp.lang.c++:2175 comp.lang.c:14488 comp.lang.forth:713 comp.lang.fortran:1580 comp.lang.misc:2266 comp.arch:7429 Path: utzoo!utgpu!watmath!clyde!att!pacbell!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: <793@quintus.UUCP> Date: 2 Dec 88 08:14:30 GMT References: <949@taux01.UUCP> <606@poseidon.ATT.COM> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 33 In article <1032@l.cc.purdue.edu> cik@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.