fegetexceptflag() function in C/C++ Last Updated : 25 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The fegetexceptflag() function in C/C++ is specified in header file fenv.h and gets floating point exception flags. This function store the raised exception in the point specified by flagp . Syntax: int fegetexceptflag(fexcept_t* flagp, int excepts) Parameters: The function accepts two mandatory parameters which are described below: flagp : signifies the pointer to a fexcept_t object where the representation is stored. excepts : signifies the bitmask value. Macro --> Description: FE_DIVBYZERO --> Pole error: Division by zero. FE_INEXACT --> Inexact: The result is not exact. FE_INVALID --> Domain error: At least one of the arguments is a value for which the function is not defined. FE_OVERFLOW --> Overflow range error: The result is too large. FE_UNDERFLOW --> Underflow range error: The result is too small. FE_ALL_EXCEPT --> All exceptions. Return value : The function returns two value as below: Zero: on success. Non-zero: on failure Below programs illustrate the above function: Program 1 : CPP // C++ program to illustrate // fegetexceptflag() function #include <bits/stdc++.h> using namespace std; int main() { // bitmask value fexcept_t excepts; // divided by zero exception feraiseexcept(FE_DIVBYZERO); // current state is saved fegetexceptflag(&excepts, FE_ALL_EXCEPT); cout << "Exception raised -> \n"; // print the exception occurred if (fetestexcept(FE_ALL_EXCEPT)) { if (fetestexcept(FE_DIVBYZERO)) cout << "FE_DIVBYZERO \n"; if (fetestexcept(FE_INEXACT)) cout << "FE_INEXACT \n"; if (fetestexcept(FE_INVALID)) cout << "FE_INVALID \n"; if (fetestexcept(FE_OVERFLOW)) cout << "FE_OVERFLOW \n"; if (fetestexcept(FE_UNDERFLOW)) cout << "FE_UNDERFLOW \n"; if (fetestexcept(FE_ALL_EXCEPT)) cout << "FE_ALL_EXCEPT \n"; } else cout << "None"; return 0; } Output: Exception raised -> FE_DIVBYZERO FE_ALL_EXCEPT Program 2 : CPP // C++ program to illustrate // fegetexceptflag() function #include <bits/stdc++.h> using namespace std; int main() { // bitmask value fexcept_t excepts; // raised exception feraiseexcept(FE_ALL_EXCEPT); // current state is saved fegetexceptflag(&excepts, FE_ALL_EXCEPT); cout << "Exception raised -> \n"; // print the exception occurred if (fetestexcept(FE_ALL_EXCEPT)) { if (fetestexcept(FE_DIVBYZERO)) cout << "FE_DIVBYZERO \n"; if (fetestexcept(FE_INEXACT)) cout << "FE_INEXACT \n"; if (fetestexcept(FE_INVALID)) cout << "FE_INVALID \n"; if (fetestexcept(FE_OVERFLOW)) cout << "FE_OVERFLOW \n"; if (fetestexcept(FE_UNDERFLOW)) cout << "FE_UNDERFLOW \n"; if (fetestexcept(FE_ALL_EXCEPT)) cout << "FE_ALL_EXCEPT \n"; } else cout << "None"; return 0; } Output: Exception raised -> FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW FE_ALL_EXCEPT Comment More infoAdvertise with us Next Article copysign() function in C++ A AmanSrivastava1 Follow Improve Article Tags : C++ CPP-Library C-Library Practice Tags : CPP Similar Reads fegetenv() function in C/C++ The fegetenv() function in C/C++ is specified in header file cfenv.h and attempts to store the current state of the floating-point environment in the object pointed by envp. The floating point environment is a set of status flags and control modes which includes both floating point exception and the 4 min read feupdateenv() function in C++ The feupdateenv() function in C++ first saves currently raised floating-point exceptions. It restores the floating-point environment from the given fenv_t object and then raises the exceptions which were saved previously.Syntax: int feupdateenv( fenv_t* envp ) Parameters: It accepts a single mandato 2 min read fma() function in C++ The fma() function takes three arguments a, b and c, and returns a*b+c without losing precision. The fma() function is defined in the cmath header file. If any argument passed to fma() is long double, the return type is long double. If not, the return type is double. Syntax: double fma(double a, dou 2 min read copysign() Function in C The copysign() function in C is part of the standard math library <math.h> and is used to create a floating-point number that combines the magnitude of one number with the sign of another. It copies the sign from one floating-point number and applies it to the magnitude of another floating-poi 3 min read copysign() function in C++ copysign(x, y) function returns the value with a magnitude of x and the sign of y. Examples: Input : copysign(6, -2) Output : -6 Input : copysign(-6, 2) Output : 6 Syntax: copysign(x, y); Parameters: x : Value with the magnitude y : Value with the sign Returns : Returns the value with a magnitude of 1 min read exp() function C++ The exp() function in C++ returns the exponential (Euler's number) e (or 2.71828) raised to the given argument. Syntax for returning exponential e: result=exp() Parameter: The function can take any value i.e, positive, negative or zero in its parameter and returns result in int, double or float or l 2 min read Like