Facebook Page Twitter Page LinkedIn Page
× C Standard Library


The C <fenv.h> header file declares a set of functions and macros to work with the floating-point environment. The floating-point environment is the set of floating-point status flags and control modes. Specific about the contents of the floating-point environment depend on the implementation, but the status flags generally include the floating-point exceptions and their associated information, and the control modes include at least the rounding direction.

Library Functions

Floating-point Exceptions

FunctionsDescription
feclearexcept() Clears floating-point exceptions.
feraiseexcept() Raises floating-point exceptions.
fegetexceptflag() Gets floating-point exceptions.
fesetexceptflag() Sets floating-point exceptions.

Rounding direction

FunctionsDescription
fegetround() Get rounding direction mode.
fesetround() Set rounding direction mode.

Entire environment

FunctionsDescription
fegetenv() Gets floating-point environment.
feholdexcept() Holds floating-point exceptions.

Library Macros

Floating-point Exceptions

MacrosDescription
FE_DIVBYZERO Pole error exception
FE_INEXACT Inexact result exception
FE_INVALID Invalid argument exception
FE_OVERFLOW Overflow range error exception
FE_UNDERFLOW Underflow range error exception
FE_ALL_EXCEPT All exceptions

Rounding directions

MacrosDescription
FE_DOWNWARD Rounding towards negative infinity.
FE_TONEAREST Rounding towards nearest representable value.
FE_TOWARDZERO Rounding towards zero.
FE_UPWARD Rounding towards positive infinity.

Library Pragmas

PragmasDescription
FENV_ACCESS Access to Floating-point environment.

Library Types

TypesDescription
fenv_t Floating-point environment type.
fexcept_t Floating-point exceptions type.