Stores a copy of the current floating-point environment #include <fenv.h> int fegetenv ( fenv_t *envp ); The fegetenv( ) function saves the current state of the floating-point environment in the object referenced by the pointer argument. The function returns 0 if successful; a nonzero return value indicates that an error occurred. The object type that represents the floating-point environment, fenv_t, is defined in fenv.h. It contains at least two kinds of information: floating-point status flags, which are set to indicate specific floating-point processing exceptions, and a floating-point control mode, which can be used to influence the behavior of floating-point arithmetic, such as the direction of rounding. ExampleThe fegetenv( ) and fesetenv( ) functions can be used to provide continuity of the floating-point environment between different locations in a program: static fenv_t fpenv; // Global environment variables. static jmp_buf env; /* ... */ #pragma STDC FENV_ACCESS ON fegetenv(&fpenv); // Store a copy of the floating-point environment if ( setjmp(env) == 0 ) // setjmp( ) returns 0 when actually called { /* ... Proceed normally; floating-point environment unchanged ... */ } else // Nonzero return value means longjmp( ) occurred { fesetenv(&fpenv); // Restore floating-point environment to known state /* ... */ } See Alsofegetexceptflag( ), feholdexcept( ), fesetenv( ), feupdateenv( ), feclearexcept( ), feraisexcept( ), fetestexcept( ) |