Xref: utzoo comp.lang.c++:2159 comp.lang.c:14440 comp.lang.forth:698 comp.lang.fortran:1566 comp.lang.misc:2242 comp.arch:7401
Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdahl!pyramid!nsc!datack!altnet!altos86!elxsi!len
From: len@elxsi.UUCP (Len Mills)
Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc,comp.arch
Subject: Floating remainder (was Re: Assembly or ....)
Message-ID: <1283@elxsi.UUCP>
Date: 30 Nov 88 20:45:42 GMT
References: <1388@aucs.UUCP| <729@convex.UUCP> <1961@crete.cs.glasgow.ac.uk> <949@taux01.UUCP> <1034@l.cc.purdue.edu>
Reply-To: len@elxsi.UUCP (Len Mills)
Organization: ELXSI Super Computers, San Jose
Lines: 31

In article <1034@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
>> |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, and this is not that unusual an 
>> |>instruction to demand.  It is cheap in hardware, and extremely expensive
>> |>in software--at least 4 instructions.
>I do not know if I made it clear in my initial posting, but the problem
>arises if the types of a, b, and c are floating.  Not that the quote from
>my paper specifically has i an integer.

If I understand correctly, what you are looking for is a Floating Point
Remainder instruction.  The ELXSI 6400 series include the FREM instructions
for the various IEEE floating point formats.  The behavior of these
instructions is:

   Divide Rz by Ry to produce (for non-zero quotients) a new value in Rx
   which consists of the low-order 64 bits of the rounded two's complement
   integer quotient, and replacing Rz by the remainder in floating-point
   form.  The remainder is defined to be Rz - (( Rz/Ry rounded to the
   nearest integer) * Ry), such that -0.5 * abs (divisor) <= remainder <=
   +0.5 * abs (divisor).

Of course, the RISCyness of this design is open to debate (:-).


-- 

Len Mills ...
{uunet,ucbvax!sun,lll-lcc!lll-tis,altos86,bridge2}!elxsi!len