fegetround.3m (2010 09)

f
fegetround(3M) fegetround(3M)
NAME
fegetround( ) - get floating-point rounding direction mode
SYNOPSIS
#include <fenv.h>
int fegetround(void);
DESCRIPTION
The fegetround() function gets the current rounding direction, as specified by the IEEE 754 (IEC
60559) floating-point standard.
The default rounding direction mode is round to nearest (
FE_TONEAREST).
USAGE
To use this function, compile either with the default
-Ae option or with the -Aa and -D_HPUX_SOURCE
options. Make sure your program includes <fenv.h>
.
For HP Integrity servers, specify
+Ofenvaccess
on the compiler command line or place the call to this
function under the effect of an affirmative FENV_ACCESS pragma:
#pragma STDC FENV_ACCESS ON
If the FENV_ACCESS pragma is placed outside of any top-level declarations in a file, the pragma will
apply to all declarations in the compilation following the pragma until another FENV_ACCESS pragma
is encountered or until the end of the file is reached.
If the
FENV_ACCESS pragma is placed at the beginning of a block (compound statement), the pragma
will apply until another FENV_ACCESS pragma is encountered or until the end of the block is reached.
For PA-RISC, you might need to use the
+Onomoveflops compiler option in order to prevent optimiza-
tions that can undermine the specified behavior of this function.
Link in the math library by specifying
-lm on the compiler or linker command line.
For more information, see the HP-UX floating-point guide for HP Integrity servers at the following site:
http://www.hp.com/go/fp
.
RETURN VALUE
The
fegetround() function returns the value of the rounding direction macro representing the current
rounding direction. The return value will match one of the following macros, which are defined in
<fenv.h>:
FE_TONEAREST Round to nearest. If the two nearest representable are equally near, the one
with its least significant bit zero is delivered.
FE_UPWARD Round upwards (towards +infinity).
FE_DOWNWARD Round downwards (towards -infinity).
FE_TOWARDZERO Round toward zero.
ERRORS
No errors are defined.
EXAMPLES
Save, set, and restore the rounding direction.
#include <fenv.h>
/*...*/
{
int save_round;
save_round = fegetround();
fesetround(FE_UPWARD);
/*...*/
fesetround(save_round);
/*...*/
}
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)