HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)
f
fesetenv(3M) fesetenv(3M)
NAME
fesetenv( ) - set floating-point environment
SYNOPSIS
#include <fenv.h>
Itanium(R)-based System Only
int fesetenv(const fenv_t *envp);
PA-RISC Only
void fesetenv(const fenv_t *envp);
DESCRIPTION
The fesetenv() function establishes the floating-point environment represented by the object pointed
to by envp. The argument envp must point to an object set by a call to
fegetenv() or feholdex-
cept(), or equal the macro FE_DFL_ENV.
Note that
fesetenv() merely installs the state of the floating-point exception flags represented through
its argument, and does not raise these floating-point exceptions (hence no traps will be taken).
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 Itanium-based systems, 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.
RETURN VALUE
Itanium-based System Only
This function always returns 0, indicating that the environment was successfully established.
PA-RISC Only
None.
ERRORS
No errors are defined.
EXAMPLES
Store the current floating-point environment, continue on exceptions, and then restore the previous
environment without raising the accumulated floating-point exceptions.
#include <fenv.h>
/*...*/
fenv_t holdenv;
feholdexcept(&holdenv);
/* perform operations */
fesetenv(&holdenv);
Restore the default environment:
#include <fenv.h>
/*...*/
fesetenv(FE_DFL_ENV);
HP-UX 11i Version 2: September 2004 − 1 − Hewlett-Packard Company Section 3−−305