feholdexcept

Saves the current floating-point environment and switches to nonstop mode

```#include <fenv.h>
int feholdexcept ( fenv_t *envp  );
```

Like fegetenv( ), the feholdexcept( ) function saves the current floating-point environment in the object pointed to by the pointer argument. However, feholdexcept( ) also clears the floating-point status flags and switches the floating-point environment to a nonstop mode, meaning that after any floating-point exception, normal execution continues uninterrupted by signals or traps. The function returns 0 if it succeeds in switching to nonstop floating-point processing; otherwise, the return value is nonzero.

#### Example

```/*
* Compute the hypoteneuse of a right triangle, avoiding intermediate
* overflow or underflow.
*
* (This example ignores the case of one argument having great magnitude
* and the other small, causing both overflow and underflow!)
*/
double hypoteneuse(double sidea, double sideb)
{
#pragma STDC FENV_ACCESS ON
double  sum, scale, ascaled, bscaled, invscale;
fenv_t  fpenv;
int     fpeflags;

if ( signbit( sidea ) ) sidea = fabs( sidea );
if ( signbit( sideb ) ) sideb = fabs( sideb );

feholdexcept(&fpenv);  // Save previous environment, clear exceptions,
// switch to nonstop processing.
invscale = 1.0;
sum = sidea * sidea + sideb * sideb;   // First try whether a^2 + b^2
// causes any exceptions.

fpeflags = fetestexcept(FE_UNDERFLOW | FE_OVERFLOW);    // Did it?
if ( fpeflags & FE_OVERFLOW && sidea > 1.0 && sideb > 1.0 )
{
/* a^2 + b^2 caused an overflow. Scale the triangle down. */
feclearexcept(FE_OVERFLOW);
scale = scalbn(1.0, (DBL_MIN_EXP /2 ));
invscale = 1.0 / scale;
ascaled = scale * sidea;
bscaled = scale * sideb;
sum = ascaled * ascaled + bscaled * bscaled;
}
else if (fpeflags & FE_UNDERFLOW && sidea < 1.0 && sideb < 1.0 )
{
/* a^2 + b^2 caused an underflow. Scale the triangle up. */
feclearexcept(FE_UNDERFLOW);
scale = scalbn(1.0, (DBL_MAX_EXP /2 ));
invscale = 1.0 / scale;
ascaled = scale * sidea;
bscaled = scale * sideb;
sum = ascaled * ascaled + bscaled * bscaled;
}

feupdateenv(&env);        // restore the caller's environment, and
// raise any new exceptions

/* c = (1/scale) * sqrt((a * scale)^2 + (b * scale)^2): */
return invscale * sqrt(sum);
}
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.536287,"math_prob":0.9786205,"size":2355,"snap":"2019-13-2019-22","text_gpt3_token_len":669,"char_repetition_ratio":0.14036581,"word_repetition_ratio":0.14854111,"special_character_ratio":0.29171973,"punctuation_ratio":0.1865285,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.979949,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-03-23T02:34:00Z\",\"WARC-Record-ID\":\"<urn:uuid:9b16dba3-3271-4e1f-854c-a4162cd29609>\",\"Content-Length\":\"5650\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5cce03dd-1155-42a3-8c16-a54b8e636582>\",\"WARC-Concurrent-To\":\"<urn:uuid:e0160154-af0f-450e-a774-cc0a8bb15dac>\",\"WARC-IP-Address\":\"109.75.178.101\",\"WARC-Target-URI\":\"http://books.gigatux.nl/mirror/cinanutshell/0596006977/cinanut-CHP-17-64.html\",\"WARC-Payload-Digest\":\"sha1:C6AMSV23UKCWSQBQMXRHTDTBTMDP4OOA\",\"WARC-Block-Digest\":\"sha1:GBMNHINXGS5PC5DPVZR4SOQROKLSG3PU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-13/CC-MAIN-2019-13_segments_1552912202711.3_warc_CC-MAIN-20190323020538-20190323042538-00461.warc.gz\"}"}