Standard C Library Functions fpgetround(3C)
NAME
fpgetround, fpsetround, fpgetmask, fpsetmask, fpgetsticky,
fpsetsticky - IE floating-point environment control
SYNOPSIS
#include
fprnd fpgetround(void);
fprnd fpsetround(fprnd rnddir);
fpexcept fpgetmask(void);
fpexcept fpsetmask(fpexcept mask);
fpexcept fpgetsticky(void);
fpexcept fpsetsticky(fpexcept sticky);
DESCRIPTION
There are five floating-point exceptions:
o divide-by-zero,
o overflow,
o underflow,
o imprecise (inexact) result, and
o 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.
The mask argument is formed by the logical OR operation of
the following floating-point exception masks:
FPXINV /* invalid operation exception */
FPXOFL /* overflow exception */
FPXUFL /* underflow exception */
SunOS 5.11 Last change: 29 Dec 1996 1
Standard C Library Functions fpgetround(3C)
FPXDZ /* divide-by-zero exception */
FPXIMP /* imprecise (loss of precision) */
The following floating-point rounding modes are passed to
fpsetround and returned by fpgetround().
FPRN /* round to nearest representative number */
FPRP /* round to plus infinity */
FPRM /* round to minus infinity */
FPRZ /* round to zero (truncate) */
The default environment is rounding mode set to nearest
(FPRN) and all traps disabled.
The fpsetsticky() function modifies all sticky flags. The
fpsetmask() function changes all mask bits. The fpsetmask()
function clears the sticky bit corresponding to any excep-
tion being enabled.
RETURN VALUES
The fpgetround() function returns the current rounding mode.
The fpsetround() function sets the rounding mode and returns
the previous rounding mode.
The fpgetmask() function returns the current exception
masks.
The fpsetmask() function sets the exception masks and
returns the previous setting.
The fpgetsticky() function returns the current exception
sticky flags.
The fpsetsticky() function sets (clears) the exception
sticky flags and returns the previous setting.
USAGE
The C programming language requires truncation (round to
zero) for floating point to integral conversions. The
current rounding mode has no effect on these conversions.
SunOS 5.11 Last change: 29 Dec 1996 2
Standard C Library Functions fpgetround(3C)
The sticky bit must be cleared to recover from the trap and
proceed. If the sticky bit is not cleared before the next
trap occurs, a wrong exception type may be signaled.
Individual bits may be examined using the constants defined
in .
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
MT-Level MT-Safe
SEE ALSO
isnand(3C), attributes(5)
SunOS 5.11 Last change: 29 Dec 1996 3
|