Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fpgetround(3C) — svr3 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

isnan(3C)



FPGETROUND(3C-SVR3) RISC/os Reference Manual  FPGETROUND(3C-SVR3)



NAME
     fpgetround, fpsetround, fpgetmask, fpsetmask, fpgetsticky,
          fpsetsticky - IEEE floating point environment control

SYNOPSIS
     #include <ieeefp.h>

     typedef enum {
          FPRN=0,   /* round to nearest */
          FPRP,     /* round to plus */
          FPRM,     /* round to minus */
          FPRZ,     /* round to zero (truncate) */
          } fprnd;

          fprnd fpgetround();

          fprnd fpsetround(rnddir)
          fprnd rnddir;

          #define   fpexcept int
          #define   FPXINV  0x10 /* invalid operation exception*/
          #define   FPXOFL  0x08 /* overflow exception*/
          #define   FPXUFL  0x04 /* underflow exception*/
          #define   FPXDZ   0x02 /* divide-by-zero exception*/
          #define   FPXIMP  0x01 /* imprecise (loss of precision)*/

          fpexcept fpgetmask();

          fpexcept fpsetmask(mask);
          fpexcept mask;

          fpexcept fpgetsticky();

          fpexcept fpsetsticky(sticky);
          fpexcept sticky;

DESCRIPTION
     There are five floating point exceptions: divide-by-zero,
     overflow, underflow, imprecise (inexact) result, and invalid
     operation.  When a floating point exception occurs, the
     corresponding sticky bit is set (1), and if the mask bit is
     enabled (1), the trap takes place.  These routines let the
     user change the behavior on occurrence of any of these
     exceptions, as well as change the rounding mode for floating
     point operations.

     fpgetround() returns the current rounding mode.

     fpsetround() sets the rounding mode and returns the previous
     rounding mode.

     fpgetmask() returns the current exception masks.



                        Printed 11/19/92                   Page 1





FPGETROUND(3C-SVR3) RISC/os Reference Manual  FPGETROUND(3C-SVR3)



     fpsetmask() sets the exception masks and returns the previ-
     ous setting.

     fpgetsticky() returns the current exception sticky flags.

     fpsetsticky() sets (clears) the exception sticky flags and
     returns the previous setting.

     The default environment on the 3B computer family is:

          Rounding mode set to nearest(FP_RN),
          Divide-by-zero,
          Floating point overflow, and
          Invalid  operation traps enabled.

SEE ALSO
     isnan(3C).

WARNINGS
     fpsetsticky() modifies all sticky flags. fpsetmask() changes
     all mask bits.

     Both C and F77 require truncation (round to zero) for float-
     ing point to integral conversions.  The current rounding
     mode has no effect on these conversions.

CAVEATS
     One must clear the sticky bit to recover from the trap and
     to proceed.  If the sticky bit is not cleared before the
     next trap occurs, a wrong exception type may be signaled.

     For the same reason, when calling fpsetmask() the user
     should make sure that the sticky bit corresponding to the
     exception being enabled is cleared.





















 Page 2                 Printed 11/19/92



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026