Wednesday, August 31, 2016

C Library Header – fenv

C99 adds several functions and types for fine-grained control of floating point environment. #pragma STDC FENV_ACCESS should be set to ON to access floating point environment.

The <fenv.h> header shall define the following pragma:
FENV_ACCESS access floating-point environment

The <fenv.h> header shall define the following macro constants:
FE_DFL_ENV default floating-point environment(C99)
FE_DIVBYZERO floating-point exceptions - pole error occurred in an earlier floating-point operation(C99)
FE_INEXACT floating-point exceptions - inexact result: rounding was necessary to store the result of an earlier floating-point operation(C99)
FE_INVALID floating-point exceptions - domain error occurred in an earlier floating-point operation(C99)
FE_OVERFLOW floating-point exceptions - the result of an earlier floating-point operation was too large to be representable(C99)
FE_UNDERFLOW floating-point exceptions - the result of an earlier floating-point operation was subnormal with a loss of precision(C99)
FE_ALL_EXCEPT floating-point exceptions - bitwise OR of all supported floating-point exceptions(C99)
FE_DOWNWARD floating-point rounding direction - rounding towards negative infinity(C99)
FE_TONEAREST floating-point rounding direction - rounding towards nearest integer(C99)
FE_TOWARDZERO floating-point rounding direction - rounding towards zero(C99)
FE_UPWARD floating-point rounding direction - rounding towards positive infinity(C99)

The <fenv.h> header shall define the following functions:
fegetenv stores the current floating point environment(C99)
fesetenv sets current floating-point environment(C99)
feholdexcept saves the environment, clears all status flags and ignores all future errors(C99)
feupdateenv restores the floating-point environment and raises the previously raise exceptions(C99)
feclearexcept clears exceptions - clears the specified floating-point status flags(C99)
feraiseexcept raises the specified floating-point exceptions(C99)
fegetexceptflag stores the state of the specified floating-point status flags (C99)
fesetexceptflag sets current status flags(C99)
fegetround gets current rounding direction(C99)
fesetround sets current rounding direction(C99)
fetestexcept determines which of the specified floating-point status flags are set(C99)

The <fenv.h> header shall define the following type:
fenv_t floating-point environment type
fexcept_t floating-point exception type



Related topics:
<assert.h>   |   <complex.h>   |   <ctype.h>   |   <errno.h>   |   <float.h>   |   Standard Library in C

List of topics: C Programming

No comments:

Post a Comment