function
<cfenv>
feupdateenvint feupdateenv (const fenv_t* envp);
Update floating-point environment
Attempts to establish the state of the floating-point environment as represented by the object pointed by envp. It then attempts to raise the exceptions that were set in the floating-point environment before the call.Programs calling this function shall ensure that pragma FENV_ACCESS is enabled for the call.
FE_
).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* feholdexcept/feupdateenv example */
#include <stdio.h> /* printf, puts */
#include <fenv.h> /* feholdexcept, feclearexcept, fetestexcept, feupdateenv, FE_* */
#include <math.h> /* log */
#pragma STDC FENV_ACCESS on
double log_zerook (double x) {
fenv_t fe;
feholdexcept(&fe);
x=log(x);
feclearexcept (FE_OVERFLOW|FE_DIVBYZERO);
feupdateenv(&fe);
return x;
}
int main ()
{
feclearexcept (FE_ALL_EXCEPT);
printf ("log(0.0): %f\n", log_zerook(0.0));
if (!fetestexcept(FE_ALL_EXCEPT))
puts ("no exceptions raised");
return 0;
}
log(0.0): -inf no exceptions raised
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