HPlogo HP-UX Reference > F

feholdexcept(3M)

HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

feholdexcept() — save floating-point environment

SYNOPSIS

#include <fenv.h>

int feholdexcept(fenv_t *envp);

DESCRIPTION

The feholdexcept() function saves the current floating-point environment in the object pointed to by the argument envp. This function also clears the floating-point exception flags and disables all traps.

Use feholdexcept() with feupdateenv() to hide spurious floating-point exceptions. Use it with fesetenv() to hide all floating-point exceptions.

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(R)-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 optimizations 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

The feholdexcept() function returns a zero value, indicating the successful disabling of any traps.

ERRORS

No errors are defined.

EXAMPLES

Store the current floating-point environment in holdenv, hide spurious underflow exceptions, and continue on any floating-point exceptions that occur until the call to feupdateenv() is encountered.

#include <fenv.h> /*...*/ fenv_t holdenv; feholdexcept(&holdenv); /* perform operations */ if (/* test for spurious underflow */) feclearexcept(FE_UNDERFLOW); feupdateenv(&holdenv); /* raise accumulated exceptions */

STANDARDS CONFORMANCE

feholdexcept() : ISO/IEC C99 (including Annex F, "IEC 60559 floating-point arithmetic")