Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::overflow_error

 

std::overflow_error (a derived class from std::runtime_error) is thrown if a 'mathematical overflow occurs'. I did not yet succeed in producing such a mathematical overflow.

 

#include <cmath>
#include <iostream>
#include <stdexcept>

int main()
{
  try
  {
    //Too bad std::fmod does not throw std::overflow_error :-(
    const double x = std::fmod(1.0,0.0);
    std::cout << x;
  }
  catch (std::overflow_error& e)
  {
    //Will not get here :-(
    std::cout << e.what();
  }
}

 

Screen output:

 

-nan

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict