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 rounding direction mode.
int fegetenv( fenv_t* envp )
Parameter : The function accepts one mandatory parameter envp which specifies an object where the state of the floating-point environment is stored.
Return value: The function returns two values as below:
- On success, It returns zero.
- On failure, It returns nonzero.
Below programs illustrate the above function:
Program 1 :
Initial environment : Exception raised -> None Rounding mode is ->FE_TONEAREST Final environment : Exception raised -> FE_INVALID Rounding mode is ->FE_DOWNWARD
Program 2 :
Initial environment : Exception raised -> None Rounding mode is ->FE_TONEAREST Final environment : Exception raised -> FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW Rounding mode is ->FE_DOWNWARD
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Function Overloading vs Function Overriding in C++
- How to call function within function in C or C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- arc function in C
- fma() function in C++
- div() function in C++
- exp() function C++
- log() function in C++
- scalbn() function in C++
- tolower() function in C
- wmemmove() function in c++
- localtime() function in C++
- toupper() function in C
- difftime() function in C++
- wcscat() function in C++
- wcsncpy() function in C++ with example
- imag() function in C++
- real() function in C++
- wcstok() function in C++ with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.