29 Numerics library [numerics]

29.4 The floating-point environment [cfenv]

29.4.1 Header <cfenv> synopsis [cfenv.syn]

#define FE_ALL_EXCEPT see below
#define FE_DIVBYZERO see below
#define FE_INEXACT see below
#define FE_INVALID see below
#define FE_OVERFLOW see below
#define FE_UNDERFLOW see below

#define FE_DOWNWARD see below
#define FE_TONEAREST see below
#define FE_TOWARDZERO see below
#define FE_UPWARD see below

#define FE_DFL_ENV see below

namespace std {
  // types
  using fenv_t    = object type;
  using fexcept_t = integer type;

  // functions
  int feclearexcept(int except);
  int fegetexceptflag(fexcept_t* pflag, int except);
  int feraiseexcept(int except);
  int fesetexceptflag(const fexcept_t* pflag, int except);
  int fetestexcept(int except);

  int fegetround();
  int fesetround(int mode);

  int fegetenv(fenv_t* penv);
  int feholdexcept(fenv_t* penv);
  int fesetenv(const fenv_t* penv);
  int feupdateenv(const fenv_t* penv);
}
The contents and meaning of the header <cfenv> are the same as the C standard library header <fenv.h>.
[Note
:
This International Standard does not require an implementation to support the FENV_­ACCESS pragma; it is implementation-defined ([cpp.pragma]) whether the pragma is supported.
As a consequence, it is implementation-defined whether these functions can be used to test floating-point status flags, set floating-point control modes, or run under non-default mode settings.
If the pragma is used to enable control over the floating-point environment, this International Standard does not specify the effect on floating-point evaluation in constant expressions.
end note
]
The floating-point environment has thread storage duration ([basic.stc.thread]).
The initial state for a thread's floating-point environment is the state of the floating-point environment of the thread that constructs the corresponding thread object ([thread.thread.class]) at the time it constructed the object.
[Note
:
That is, the child thread gets the floating-point state of the parent thread at the time of the child's creation.
end note
]
A separate floating-point environment shall be maintained for each thread.
Each function accesses the environment corresponding to its calling thread.
See also: ISO C 7.
6