Created
January 5, 2015 02:26
-
-
Save ashwin/a29abf880ef66a0ca45f to your computer and use it in GitHub Desktop.
How to check for math error in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checking for math error in C++ | |
#include <cerrno> | |
#include <cmath> | |
#include <cstring> | |
#include <iostream> | |
std::cout << log(0) << std::endl; | |
if (errno) | |
std::cout << std::strerror(errno) << std::endl; | |
if (errno == EDOM) | |
std::cout << "Domain error\n"; | |
if (errno == ERANGE) | |
std::cout << "Range error\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment