Important: The information in this document is obsolete and should not be used for new development.
Floating-Point Environment Header File (fenv.h)
The filefenv.h
defines a collection of functions designed to provide access to the floating-point environment for numerical programming. The filefenv.h
declares many functions in support of numerical programming. It provides a set of environmental controls similar to the ones found in the SANE library.Constants
#ifndef __FENV__ #define __FENV__Floating-Point Exception Flags
#define FE_INEXACT 0x02000000 /* inexact */ #define FE_DIVBYZERO 0x04000000 /* divide-by-zero */ #define FE_UNDERFLOW 0x08000000 /* underflow */ #define FE_OVERFLOW 0x10000000 /* overflow */ #define FE_INVALID 0x20000000 /* invalid */ /* The bitwise OR of all exception macros */ #define FE_ALL_EXCEPT ( FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \ FE_OVERFLOW | FE_INVALID )Rounding Direction Modes
#define FE_TONEAREST 0x00000000 #define FE_TOWARDZERO 0x00000001 #define FE_UPWARD 0x00000002 #define FE_DOWNWARD 0x00000003 #define FE_DFL_ENV &_FE_DFL_ENV /* pointer to default environment*/Data Types
typedef long int fenv_t; typedef long int fexcept_t; /* Definition of pointer to IEEE default environment object */ extern fenv_t _FE_DFL_ENV; /* default environment object */Functions
Controlling the Floating-Point Exceptions
void feclearexcept(int excepts); void fegetexcept(fexcept_t *flagp, int excepts); void feraiseexcept(int excepts); void fesetexcept(const fexcept_t *flagp, int excepts); int fetestexcept(int excepts);Controlling the Rounding Direction
int fegetround(void); int fesetround(int round);Controlling the Floating-Point Environment
void fegetenv (fenv_t *envp); int feholdexcept (fenv_t *envp); void fesetenv (const fenv_t *envp); void feupdateenv (const fenv_t *envp); #endif