411 REFERENCE · Wikibooks
C programming/fenv.h
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
fenv.h is a header file containing various functions and macros for manipulating the floating-point environment.bd fenv.h SUS floating-point environment
This header declares two types, fenv_t (represents the whole floating-point environment) and fexcept_t (represents the floating-point status flags). It also declares several feature macros, beginning with FE_ and a capital letter.
Functions
Other than fegetround and fetestexcept, these functions return zero/non-zero on success/failure.
Declaration Descriptionint sh feclearexcept SUS inline(int excepts); clear exceptions specified by exceptsint sh fegetenv SUS inline(fenv_t *penv); store current floating-point environment in penvint sh fegetexceptflag SUS inline(fexcept_t *pflag, int excepts); store current status flags in pflagsint sh fegetround SUS inline(void); retrieve current rounding directionint sh feholdexcept SUS inline(fenv_t *penv); save current floating-point environment to penv and clear all exceptionsint sh feraiseexcept SUS inline(int excepts); raise floating-point exceptionsint sh fesetenv SUS inline(const fenv_t *penv); set current floating-point environment to penvint sh fesetexceptflag SUS inline(const fexcept_t *pflags, int excepts); set current status flags to those stored in pflagsint sh fesetround SUS inline(int round); set current rounding direction to roundint sh fetestexcept SUS inline(int excepts); test whether certain exceptions have been raisedint sh feupdateenv SUS inline(const fenv_t *penv); restore floating-point environment penv, but keep current exceptionsint fesetprec(int prec) Sets the precision mode to the value specified by prec.
References