| 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) | ||||
feraiseexcept (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) | ||||
(C++11) |
Defined in header <cfenv> | ||
int feraiseexcept(int excepts); | (since C++11) | |
Attempts to raise all floating point exceptions listed inexcepts (a bitwise OR of thefloating point exception macros). If one of the exceptions isFE_OVERFLOW orFE_UNDERFLOW, this function may additionally raiseFE_INEXACT. The order in which the exceptions are raised is unspecified, except thatFE_OVERFLOW andFE_UNDERFLOW are always raised beforeFE_INEXACT.
Contents |
| excepts | - | bitmask listing the exception flags to raise |
0 if all listed exceptions were raised, non-zero value otherwise.
#include <cfenv>#include <iostream> // #pragma STDC FENV_ACCESS ON int main(){std::feclearexcept(FE_ALL_EXCEPT);constint r= std::feraiseexcept(FE_UNDERFLOW|FE_DIVBYZERO);std::cout<<"Raising divbyzero and underflow simultaneously "<<(r?"fails":"succeeds")<<" and results in\n"; constint e=std::fetestexcept(FE_ALL_EXCEPT);if(e&FE_DIVBYZERO)std::cout<<"division by zero\n";if(e&FE_INEXACT)std::cout<<"inexact\n";if(e&FE_INVALID)std::cout<<"invalid\n";if(e&FE_UNDERFLOW)std::cout<<"underflow\n";if(e&FE_OVERFLOW)std::cout<<"overflow\n";}
Output:
Raising divbyzero and underflow simultaneously succeeds and results indivision by zerounderflow
(C++11) | clears the specified floating-point status flags (function)[edit] |
(C++11) | determines which of the specified floating-point status flags are set (function)[edit] |
C documentation forferaiseexcept | |