fpgetround(3C) DG/UX 5.4R3.00 fpgetround(3C)
NAME
fpgetround, fpsetround, fpgetmask, fpsetmask, fpgetsticky,
fpsetsticky - IEEE floating-point environment control
SYNOPSIS
#include <ieeefp.h>
fp_rnd fpgetround ();
fp_rnd fpsetround (rnd_dir)
fp_rnd rnd_dir;
fp_except fpgetmask ();
fp_except fpsetmask (mask)
fp_except mask;
fp_except fpgetsticky ();
fp_except fpsetsticky (sticky)
fp_except sticky;
DESCRIPTION
There are five floating-point exceptions: divide-by-zero, overflow,
underflow, imprecise (inexact) result, and invalid operation. When a
floating-point exception is detected, a trap (SIGFPE) occurs only
when the corresponding mask bit is enabled. Otherwise, the
corresponding sticky bit is set and the standard IEEE-specified fixup
is performed on the result. These routines let the user control the
behavior on occurrence of any of these exceptions, as well as the
rounding mode for floating-point operations.
fpgetround returns the current rounding mode. fpsetround sets the
rounding mode and returns the previous rounding mode. The
enumeration type fp_rnd (defined in <ieeefp.h>) comprises the
following rounding modes:
FP_RN /* round to nearest */
FP_RP /* round to plus */
FP_RM /* round to minus */
FP_RZ /* round to zero (truncate) */
fpgetmask returns the current exception masks.
fpsetmask sets the exception masks and returns the previous setting.
fpgetsticky returns the current exception sticky flags.
fpsetsticky sets (clears) the exception sticky flags and returns the
previous setting.
Licensed material--property of copyright holder(s) 1
fpgetround(3C) DG/UX 5.4R3.00 fpgetround(3C)
The type fp_except is defined in <ieeefp.h>, along with the following
exception masks:
FP_X_INV /* invalid operation exception */
FP_X_OFL /* overflow exception */
FP_X_UFL /* underflow exception */
FP_X_DZ /* divide-by-zero exception */
FP_X_IMP /* imprecise (loss of precision) */
The following defaults are in effect unless your program includes the
file <ieeefp.h>:
Rounding mode set to nearest (FP_RN).
In the COFF environments (see intro(3)), these traps are enabled:
Divide-by-zero,
floating-point overflow, and
invalid operation.
In the ELF environment (see intro(3)), no traps are enabled except
invalid operation exceptions upon attempted operations on
Signaling NaNs.
If your program includes the file <ieeefp.h>, all traps are disabled.
Considerations for Threads Programming
+------------+-----------------------------+
| | async- |
|function | reentrant cancel cancel |
| | point safe |
+------------+-----------------------------+
|fpgetmask | Y N N |
|fpsetmask | Y N N |
|fpgetround | Y N N |
|fpsetround | Y N N |
|fpgetsticky | Y N N |
|fpsetsticky | Y N N |
+------------+-----------------------------+
SEE ALSO
reentrant(3), isnan(3C).
CAUTIONS
fpsetsticky modifies all sticky flags. fpsetmask changes all mask
bits.
Both C and F77 require truncation (round to zero) for floating-point
to integral conversions. The rounding mode has no effect on these
Licensed material--property of copyright holder(s) 2
fpgetround(3C) DG/UX 5.4R3.00 fpgetround(3C)
conversions.
The sticky bit is never set when the trap for the exception is
enabled. As a result, it is currently impossible to determine what
IEEE floating-point exception occurred from a C-coded signal handler.
Licensed material--property of copyright holder(s) 3