fpgetround(3C)fpgetround(3C)NAME
fpgetround, fpsetround, fpgetmask, fpsetmask, fpgetsticky, fpsetsticky
- The IEEE floating-point environment control
SYNOPSIS
#include <ieeefp.h>
fp_rnd fpgetround(
void ); fp_rnd fpsetround(
fp_rnd rnd_dir ); fp_except fpgetmask(
void ); fp_except fpsetmask(
fp_except mask ); fp_except fpgetsticky(
void ); fp_except fpsetsticky(
fp_except sticky );
LIBRARY
SVR4 Library (libsvr4)
DESCRIPTION
There are five floating point exceptions: divide by zero, overflow,
under flow, 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. /* invalid operation exception */ /* overflow exception */
/* underflow exception */ /* divide-by-zero exception */ /* imprecise
(loss of precision) */ /* round to nearest representative number */ /*
round to plus infinity */ /* round to minus infinity */ /* round to
zero (truncate) */
The fpgetround() function returns the current rounding mode.
The fpsetround() function sets the rounding mode and returns the previ‐
ous rounding mode.
The fpgetmask() function returns the current exception masks.
The fpgetsticky() function returns the current exception sticky flags.
The fpsetsticky() function sets (clears) the exception sticky flags and
returns the previous setting.
The default environment is rounding mode set to nearest (FP_RN) and all
traps disabled.
NOTES
The fpsetsticky() function modifies all sticky flags. The fpsetmask()
function changes all mask bits. The fpsetmask() function clears the
sticky bit corresponding to any exception being enabled.
C requires truncation (round to zero) for floating point to integral
conversions. The current rounding mode has no effect on these conver‐
sions.
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.
If the <math.h> and the <ieeefp.h> headers are both included in the
same source file, then <math.h> always must be included before
<ieeefp.h>.
Some of the files that are referenced by absolute path in the System V
Environment for Tru64 UNIX reference pages actually may be located rel‐
ative to /usr/opt/svr4.
RESTRICTIONS
Threads are safe for use in threaded applications except under speci‐
fied conditions.
The fpsetround(), fpsetmask(), fpsetsticky() functions are only thread
safe when the application takes precaution not to allow multiple
threads to call these routines at the same time, for these routines
set the floating point control registers, which are shared among all
threads.
The fpgetround(), fpgetmask(), fpgetsticky() functions are all thread
safe without restrictions.
SEE ALSO
Functions: isnan(3)fpgetround(3C)