Graceful error recovery with arithmetic

M

mmacrobert

Hi there,
I'm having trouble making some code do a "graceful" recovery for
mathematical operations. Certain functions e.g. log10, will call
"matherr" and provides an avenue for intervention in a result.

How can I do the same in a portable fashion for arithmetic operations?
For example, catching dividing by zero using scalars (int's,doubles
etc.)?

Is there a standard way of getting C++ to throw some kind of
std::exception when a math-error results? Is there any standard
implementations for this somewhere?

Thanks,
Martin
 
V

Victor Bazarov

mmacrobert said:
I'm having trouble making some code do a "graceful" recovery for
mathematical operations. Certain functions e.g. log10, will call
"matherr" and provides an avenue for intervention in a result.

How can I do the same in a portable fashion for arithmetic operations?

You can't. The only portable way is to _prevent_ it instead of _dealing_
with it when it's happened.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top