fegetenv()

Retrieves the current floating-point environment.

  #include <fenv.h>
  
  void fegetenv(fenv_t *envp);    
Parameter

envp

Pointer to a floating-point environment object.

Remarks

This function is used when a programmer wants to save the current floating-point environment, that is the state of all the floating-point exception flags and rounding direction. In the example that follows the stored environment is used to hide any floatingpoint exceptions raised during an interim calculation.

This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.

Listing: Example of fegetenv()

#include <fenv.h>

#pragma STDC FENV_ACCESS on

int main(void)

{

float x = 0.0, y = 0.0;

fenv_t env1, env2;

feclearexcept(FE_ALL_EXCEPT);

fesetenv(FE_DFL_ENV);

x = x + y; /* Might raise exception. */

fegetenv(&env1);

y = y * x; /* Might raise exception. */

fegetenv(&env2);

return 0;

}