次の方法で共有


feholdexcept

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at feholdexcept2.

Saves the current floating-point environment in the specified object, clears the floating-point status flags, and, if possible, puts the floating-point environment into non-stop mode.

Syntax

int feholdexcept(  
   fenv_t *penv  
);  
  

Parameters

penv
Pointer to an fenv_t object to contain a copy of the floating-point environment.

Return Value

Returns zero if and only if the function is able to successfully turn on non-stop floating-point exception handling.

Remarks

The feholdexcept function is used to store the state of the current floating point environment in the fenv_t object pointed to by penv, and to set the environment to not interrupt execution on floating-point exceptions. This is known as non-stop mode. This mode continues until the environment is restored using fesetenv or feupdateenv.

You can use this function at the beginning of a subroutine that needs to hide one or more floating-point exceptions from the caller. To report an exception, you can simply clear the unwanted exceptions by using feclearexcept, and then end the non-stop mode with a call to feupdateenv.

To use this function, you must turn off floating-point optimizations that could prevent access by using the #pragma fenv_access(on) directive prior to the call. For more information, see fenv_access.

Requirements

Function C header C++ header
feholdexcept <fenv.h> <cfenv>

For additional compatibility information, see Compatibility.

See Also

Alphabetical Function Reference
feclearexcept
fesetenv
feupdateenv