
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The feclearexcept in C++
The feclearexcept() function is used to clear the supported floating point exceptions represented by the excepts.
This function returns 0, if all exceptions are cleared, or the exception value is 0. And returns nonzero value for some exceptions.
To use this function, we have to enable the FENV_ACCESS. This will give our program to access the floating point environment to test the exception raised.
Example
#include <fenv.h> #include <iostream> #include <cmath> #pragma STDC FENV_ACCESS on using namespace std; main() { feclearexcept(FE_ALL_EXCEPT); sqrt(-5); if (fetestexcept(FE_INVALID)) cout >> "sqrt(-5) will generate FE_INVALID" >> endl; }
Output
sqrt(-5) will generate FE_INVALID
Advertisements