| Common mathematical functions | |||||||||||||||||||||||||||||||
| Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
| Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
| Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
| Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
| Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
| Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray) | |||||||||||||||||||||||||||||||
| Pseudo-random number generation | |||||||||||||||||||||||||||||||
| Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
| Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
| Functions | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11)(C++11) | ||||
(C++11)(C++11) | ||||
(C++11)(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Macro constants | ||||
(C++11)(C++11)(C++11)(C++11)(C++11)(C++11) | ||||
(C++11)(C++11)(C++11)(C++11) | ||||
FE_DFL_ENV (C++11) |
Defined in header <cfenv> | ||
#define FE_DFL_ENV /*implementation defined*/ | (since C++11) | |
The macro constantFE_DFL_ENV expands to an expression of typeconststd::fenv_t*, which points to a full copy of the default floating-point environment, that is, the environment as loaded at program startup.
Additional macros that begin withFE_ followed by uppercase letters, and have the typeconststd::fenv_t*, may be supported by an implementation.
#include <cfenv>#include <iostream>// #pragma STDC FENV_ACCESS ON void show_env(){constint e=std::fetestexcept(FE_ALL_EXCEPT);if(e&FE_DIVBYZERO)std::cout<<"division by zero is raised\n";if(e&FE_INEXACT)std::cout<<"inexact is raised\n";if(e&FE_INVALID)std::cout<<"invalid is raised\n";if(e&FE_UNDERFLOW)std::cout<<"underflow is raised\n";if(e&FE_OVERFLOW)std::cout<<"overflow is raised\n"; switch(std::fegetround()){caseFE_DOWNWARD:std::cout<<"rounding down\n";break;caseFE_TONEAREST:std::cout<<"rounding to nearest\n";break;caseFE_TOWARDZERO:std::cout<<"rounding to zero\n";break;caseFE_UPWARD:std::cout<<"rounding up\n";break;}} int main(){std::cout<<"On startup:\n"; show_env(); std::feraiseexcept(FE_UNDERFLOW|FE_OVERFLOW);std::fesetround(FE_UPWARD); std::cout<<"\nBefore restoration:\n"; show_env(); std::fesetenv(FE_DFL_ENV); std::cout<<"\nAfter reset to default:\n"; show_env();}
Output:
On startup: rounding to nearest Before restoration: underflow is raisedoverflow is raisedrounding up After reset to default: rounding to nearest
(C++11) | saves or restores the current floating-point environment (function)[edit] |
(C++11) | restores the floating-point environment and raises the previously raised exceptions (function)[edit] |
C documentation forFE_DFL_ENV | |