HPUX fpgetmask[3m]






 fpgetround(3M)                                               fpgetround(3M)





 NAME
      fpgetround(), fpsetround(), fpgetmask(), fpsetmask(), fpgetsticky(),
      fpsetsticky(), fpsetdefaults(), fpgetcontrol(), fpsetcontrol(),
      fpgetfastmode(), fpsetfastmode() - floating-point mode-control
      functions

 SYNOPSIS
      #include <math.h>

      fp_rnd fpgetround(void);

      fp_rnd fpsetround(fp_rnd mode);

      fp_except fpgetmask(void);

      fp_except fpsetmask(fp_except value);

      fp_except fpgetsticky(void);

      fp_except fpsetsticky(fp_except value);

      int fpgetfastmode(void);

      int fpsetfastmode(int value);

      void fpsetdefaults(void);

      fp_control fpgetcontrol(void);

      fp_control fpsetcontrol(fp_control value);

 DESCRIPTION
      The fpgetround() suite of functions allows programmers to manipulate
      the floating-point control register (also called the floating-point
      status register).

      fpgetround() returns the current rounding mode.  The type of the
      returned value, fp_rnd, is defined as follows in <math.h>:

           typedef enum {
               FP_RZ=0,   /* Round toward zero */
               FP_RN,     /* Round to nearest */
               FP_RP,     /* Round toward positive infinity */
               FP_RM,     /* Round toward negative infinity */
               } fp_rnd;

      The default value is FP_RN.  Round-to-nearest mode rounds to the
      representable value closest to the true value.  If two representable
      values are equally close to the true value, the system chooses the one
      whose least significant bit is zero.




 Hewlett-Packard Company            - 1 -     HP-UX Release 9.0: August 1992






 fpgetround(3M)                                               fpgetround(3M)





      fpsetround() sets the rounding mode to the specified value of type
      fp_rnd and returns the previous rounding mode.

      There are five floating-point exceptions: divide-by-zero, overflow,
      underflow, imprecise (inexact) result, and invalid operation.  If a
      floating-point exception occurs and the corresponding exception trap
      enable bit is set to 1, the trap takes place.  If an exception occurs
      and the exception trap enable bit is set to 0, the corresponding
      exception flag is set to 1 and no trap takes place.  The exception-
      trap-enable bits are sometimes called mask bits; the exception flags
      are sometimes called sticky bits.  The routines fpgetmask() and
      fpgetsticky() return the current settings of these bits.  To change
      the settings of these bits, use fpsetmask() and fpsetsticky().

      fpgetmask() returns the current exception trap enable bits.  The type
      of the returned value, fp_except, is defined as int in <math.h>.  The
      floating-point exception types are defined as follows in <math.h>:

           #define FP_X_INV       0x10  /* invalid operation exception */
           #define FP_X_DZ        0x08  /* divide-by-zero exception */
           #define FP_X_OFL       0x04  /* overflow exception */
           #define FP_X_UFL       0x02  /* underflow exception */
           #define FP_X_IMP       0x01  /* imprecise (inexact result) */
           #define FP_X_CLEAR     0x00  /* simply zero to clear all flags */

      fpsetmask() sets or clears the exception trap enable bits and returns
      the previous setting.  The argument is an expression of type
      fp_except.  (To set or clear the exception trap enable bits at compile
      time, use the compiler option +FPstring).

      fpgetsticky() returns the current exception flags.

      fpsetsticky() sets or clears the exception flags and returns the
      previous setting.  The argument is an expression of type fp_except.

      fpgetfastmode() and fpsetfastmode() allow the programmer to change the
      way the system handles underflow.  Fast underflow mode, also known as
      fastmode, is an alternative to IEEE-754-compliant underflow mode.  On
      Series 700/800 systems, underflow involves a fault into the kernel,
      where the IEEE-mandated conversion of the result into a denormalized
      value or zero is accomplished by software emulation.  On some PA1.1
      -based systems, fastmode causes the hardware to simply substitute a
      zero for the result of an operation, with no fault occurring.  This
      may be a significant performance optimization for applications that
      underflow frequently.  Fastmode also causes denormalized floating-
      point operands to be treated as if they were true zero operands.

      fpgetfastmode() returns the current fastmode setting: 1 if fastmode is
      set, 0 if the default IEEE-754-compliant underflow mode is set.  On
      systems that do not support fastmode, this function returns an
      undefined value.



 Hewlett-Packard Company            - 2 -     HP-UX Release 9.0: August 1992






 fpgetround(3M)                                               fpgetround(3M)





      On systems that support fastmode, fpsetfastmode() sets fastmode to
      either 1 (fastmode) or 0 (IEEE-754-compliant underflow mode) and
      returns the previous setting.  On systems that do not support
      fastmode, this function has no effect.

      fpsetdefaults() changes the default environment on Series 700
      workstations, which is

           Round to nearest (FP_RN)
           All exception flags cleared (FP_X_CLEAR)
           All exception traps disabled
           Fast underflow mode disabled

      fpsetdefaults() changes these defaults to more useful values.
      Specifically, it enables traps for the invalid operation, divide-by-
      zero, and overflow exceptions, while leaving the underflow and
      inexact-result exception traps disabled.  It sets the environment as
      follows:

           Round to nearest (FP_RN)
           All exception flags cleared (FP_X_CLEAR)
           All exception traps enabled except underflow and inexact result
           (FP_X_INV+FP_X_DZ+FP_X_OFL)
           Fast underflow mode enabled (if the system supports it)

      fpgetcontrol() and fpsetcontrol() access fp0, the floating-point
      unit's control register (also called the status register).

      fpgetcontrol() returns the value of fp0.  The type of the returned
      value, fp_control, is defined as long in <math.h>.

      fpsetcontrol() sets the value of fp0 and returns the previous value.
      For the format of fp0, see the HP-UX Floating-Point Guide or the PA-
      RISC 1.1 Architecture and Instruction Set Reference Manual.

 DEPENDENCIES
    Series 300/400
      These functions are not supported on Series 300/400 systems.

    Series 700/800
      All of these functions are provided in the PA1.1 versions of the math
      library only.  The +DA1.1 linker option (default on Series 700
      systems) links in a PA1.1 version automatically.  A PA1.1 library can
      be linked in explicitly.  For more information, see the HP-UX
      Floating-Point Guide.

 WARNINGS
      fpsetsticky() modifies all exception flags.  fpsetmask() modifies all
      exception trap enable bits.





 Hewlett-Packard Company            - 3 -     HP-UX Release 9.0: August 1992






 fpgetround(3M)                                               fpgetround(3M)





      Both C and FORTRAN require truncation (rounding to zero) for
      floating-point to integer conversions.  The current rounding mode has
      no effect on these conversions.



















































 Hewlett-Packard Company            - 4 -     HP-UX Release 9.0: August 1992