It sets the specified floating point rounding direction or the “current rounding direction” which is expected to be one of the floating point rounding macros.
It is used with rint(), nearbyint() and other rounding functions in C++.
Syntax: int fesetround( int round ); where round can be FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO Header File : cfenv Return : The fesetround() function returns 0 on success and the rounding direction is applied to the required number.
Errors and Exceptions : The function takes only FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO as arguments, otherwise it returns an error.
Application : fesetround() function can be used with rint(), nearbyint() and other rounding functions of the math header to apply the “current rounding direction”
4 3 3 4
It is used to obtain the value of the floating point rounding macro that corresponds to the current rounding direction. It is used with rint(), nearbyint() and other rounding functions in C++.
Syntax : int fegetround(); No parameter Header File : cfenv Return : The fegetround() function returns the floating point rounding macro describing the current rounding direction. Rounding Macros: 1.FE_DOWNWARD 2.FE_TONEAREST 3.FE_TOWARDZERO 4.FE_UPWARD
Errors and Exceptions :
- The function does not take any arguments, therefore returns an error if a parameter is passed
- If no rounding direction is specified using fesetround(), it returns the macro FE_TONEAREST
Application : fegetround() function can be used with rint(), nearbyint() and other rounding functions of the math header to get the “current rounding direction” using macros.
In this program we will be checking and printing the macro returned by the fegetround() function.
FE_UPWARD FE_DOWNWARD FE_TOWARDZERO FE_TONEAREST
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- C++ bitset and its application
- is_permutation() in C++ and its application for anagram search
- Understanding ShellExecute function and it's application to open a list of URLs present in a file using C++ code
- isspace() in C/C++ and its application to count whitespace characters
- iscntrl() in C++ and its application to find control characters
- Chat application between two processes using signals and shared memory
- unordered_multimap and its application
- Full screen OpenCV / GtK application in C++ running on Raspberry PI
- Synchronous Chatting Application using C++ boost::asio
- Data Type Ranges and their macros in C++
- Enum Classes in C++ and Their Advantage over Enum DataType
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Queries to insert, delete one occurrence of a number and print the least and most frequent element
- Get first and last elements from Array and Vector in CPP
- Similarities and Differences between Ruby and C++
- Generate an array of given size with equal count and sum of odd and even numbers
- Similarities and Difference between Java and C++
- INT_MAX and INT_MIN in C/C++ and Applications
- Change/add only one character and print '*' exactly 20 times
- Comma in C and C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.