Provides access to the floating-point environment.
The following macros and functions are all implementation-defined.
Attempts to clear a floating-point exception.
#include <fenv.h>
long feclearexcept(long e);
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Gets the state of a floating-point flag.
#include <fenv.h>
long fegetexceptflag(fexcept_t *f, long e);
f Pointer to area to store the exception flag state
e Value indicating the exception flag whose state is to be acquired
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Attempts to generate a floating-point exception.
#include <fenv.h>
long feraiseexcept(long e);
e Value indicating the exception to be generated
When generating an "overflow" or "underflow" floating-point exception, whether the feraiseexcept function also generates an "inexact" floating-point exception is implementation-defined.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Sets the state of an exception flag.
#include <fenv.h>
long fesetexceptflag(const fexcept_t *f, long e);
f Pointer to the source location from which the exception flag state is to be acquired
e Value indicating the exception flag whose state is to be set
Before calling the fesetexceptflag function, specify a flag state in the source location through the fegetexceptflag function.
The fesetexceptflag function only sets the flag state without generating the corresponding floating-point exception.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Checks the exception flag states.
#include <fenv.h>
long fetestexcept(long e);
e Value indicating flags whose states are to be checked (multiple flags can be specified)
Bitwise OR of e and floating-point exception macros
A single fetestexcept function call can check multiple floating-point exceptions.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Gets the current rounding direction.
#include <fenv.h>
long fegetround(void);
Abnormal: Negative value when there is no rounding direction macro value or the rounding direction cannot be determined
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Sets the current rounding direction.
#include <fenv.h>
#include <assert.h>
long fesetround(long rnd);
0 only when the rounding direction has been set successfully
The rounding direction is not changed if the rounding direction requests through the fesetround function differs from the rounding macro value.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Gets the floating-point environment.
#include <fenv.h>
long fegetenv( fenv_t *f);
f Pointer to area to store the floating-point environment
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Saves the floating-point environment.
#include <fenv.h>
long feholdexcept(fenv_t *f);
f Pointer to the floating-point environment
0 only when the environment has been saved successfully
When saving the floating-point function environment, the feholdexcept function clears the floating-point status flags and sets the non-stop mode for all floating-point exceptions. In non-stop mode, execution continues even after a floating-point exception occurs.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Sets the floating-point environment.
#include <fenv.h>
long fesetenv(const fenv_t *f);
f Pointer to the floating-point environment
For the argument of this function, specify the environment stored or saved by the fegetenv or feholdexcept function, or the environment equal to the floating-point environment macro.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.
Sets the floating-point environment with the previously generated exceptions retained.
#include <fenv.h>
long feupdateenv(const fenv_t *f);
f Pointer to the floating-point environment to be set
For the argument of this function, specify the object stored or saved by the fegetenv or feholdexcept function call, or the floating-point environment equal to the floating-point environment macro.
Do not use this function when compiler option nofpu is selected. If used, the function returns a nonzero value, which indicates an abnormality.