function
<cfenv>
fetestexceptint fetestexcept (int excepts);
Test for floating-point exceptions
Returns the exceptions currently set, among those specified by excepts.The value returned is the bitwise OR representation of the subset of excepts that are currently set in the floating point environment. Or zero, if none of the exceptions in excepts are currently set.
Programs calling this function shall ensure that pragma FENV_ACCESS is enabled for the call.
FE_
).
Libraries may define in
<fenv.h>
only the macro values above they support (the others may not be defined).
At least all of the above macro values are defined in
<cfenv>
(even if not supported by the implementation).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* fetestexcept example */
#include <stdio.h> /* puts */
#include <fenv.h> /* feraiseexcept, fetestexcept, FE_* */
#pragma STDC FENV_ACCESS on
double fn (double x) {
/* some function for which zero is a domain and range error */
if (x==0.0) feraiseexcept(FE_INVALID|FE_OVERFLOW);
return x;
}
int main ()
{
int fe;
feclearexcept (FE_ALL_EXCEPT);
fn (0.0);
/* testing for single exception: */
if (fetestexcept(FE_OVERFLOW)) puts ("FE_OVERFLOW is set");
/* testing multiple exceptions: */
fe = fetestexcept (FE_ALL_EXCEPT);
puts ("The following exceptions are set:");
if (fe & FE_DIVBYZERO) puts ("FE_DIVBYZERO");
if (fe & FE_INEXACT) puts ("FE_INEXACT");
if (fe & FE_INVALID) puts ("FE_INVALID");
if (fe & FE_OVERFLOW) puts ("FE_OVERFLOW");
if (fe & FE_UNDERFLOW) puts ("FE_UNDERFLOW");
return 0;
}
FE_OVERFLOW is set The following exceptions are set: FE_INVALID FE_OVERFLOW
try/catch
blocks.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4