Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fpgetround(3C) — Interactive 2.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

isnan(3C)



          FPGETROUND(3C)       INTERACTIVE UNIX System       FPGETROUND(3C)



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

          SYNOPSIS
               #include <ieeefp.h>

               typedef enum {
                    FP_RN=0,   /* round to nearest */
                    FP_RM,     /* round to minus */
                    FP_RP,     /* round to plus */
                    FP_RZ,     /* round to zero (truncate) */
                    } fp_rnd;

                    fp_rnd fpgetround();

                    fp_rnd fpsetround(rnd_dir)
                    fp_rnd rnd_dir;

                    #define   fp_except int
                    #define   FP_X_INV  0x01 /* invalid operation exception*/
                    #define   FP_X_OFL  0x08 /* overflow exception*/
                    #define   FP_X_UFL  0x10 /* underflow exception*/
                    #define   FP_X_DZ   0x04 /* divide-by-zero exception*/
                    #define   FP_X_IMP  0x20 /* imprecise (loss of precision)*/
                    #define   FP_X_DNML 0x02 /* denormalization exception */

                    fp_except fpgetmask();

                    fp_except fpsetmask(mask);
                    fp_except mask;

                    fp_except fpgetsticky();

                    fp_except fpsetsticky(sticky);
                    fp_except sticky;

          DESCRIPTION
               There are six floating point exceptions: divide-by-zero,
               overflow, underflow, imprecise (inexact) result, denormali-
               zation, and invalid operation.  When a floating point excep-
               tion 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.


          Rev. C Software Development Set                            Page 1





          FPGETROUND(3C)       INTERACTIVE UNIX System       FPGETROUND(3C)



               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 Intel 80386 processor 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.

               C requires truncation (round to zero) for floating 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 floating point instruction is executed, a wrong excep-
               tion 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.



















          Rev. C Software Development Set                            Page 2



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