
PROGRAMMING NUMERIC APPLICATIONS
Note that FSCALE assumes the scale factor in ST(l) is an integral value in the range
<I X I < 1, the instruction will produce an undefined result and will not signal an exception, ,The recommended practice is to load the scale factor from a word integer to ensure correct operation.
FPREM
FPREM (partial remainder) performs modulo division of the top stack element by the next stack element, i.e., ST(l) is the modulus. FPREM produces an exact result; the precision exception does not occur. The sign of the remainder is the same as the sign of the original dividend.
FPREM operates by performing successive scaled subtractions; obtaining the exact remainder when the operands differ greatly in magnitude can consume large amounts of execution time. Because the 80287 can only be preempted between instructions, the remainder function could seriously increase interrupt latency in these cases. Accordingly, the instruction is designed to be executed iteratively in a
FPREM can reduce a magnitude difference of up to 264 in one execution. If FPREM produces a remainder that is less than the modulus, the function is complete and bit C2 of the status word condi- tion code is cleared. If the function is incomplete, C2 is set to 1; the result in ST is then called the partial remainder. Software can inspect C2 by storing the status word following execution of FPREM and
An important use for FPREM is to reduce arguments (operands) of periodic transcendental functions to the range permitted by these instructions. For example, the FPTAN (tangent) instruction requires its argument to be less than 7r/4. Using 7r /4 as a modulus, FPREM will reduce an argument so that it is in range of FPTAN. Because FPREM produces an exact result, the argument reduction does not introduce roundoff error into the calculation, even if several iterations are required to bring the argument into range. (The rounding of 7r does not create the effect of a rounded argument, but of a rounded period.)
FPREM also provides the
FRNDINT
FRNDINT (round to integer) rounds the top stack element to an integer. For example, assume that ST contains the 80287 real number encoding of the decimal value 155.625. FRNDINT will change the value to 155 if the RC field of the control word is set to down or chop, or to 156 if it is set to up or nearest.