Graceful error recovery with arithmetic

Discussion in 'C++' started by mmacrobert, Aug 4, 2005.

  1. mmacrobert

    mmacrobert Guest

    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
     
    mmacrobert, Aug 4, 2005
    #1
    1. Advertising

  2. mmacrobert wrote:
    > 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.

    > [..]
     
    Victor Bazarov, Aug 4, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Kaminski [MVP]

    graceful file upload limit error?

    Tom Kaminski [MVP], Jul 19, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    2,790
    Shan Plourde
    Jul 20, 2004
  2. Jacob H

    Graceful failures

    Jacob H, Dec 29, 2003, in forum: Python
    Replies:
    3
    Views:
    345
    Samuel Walters
    Dec 31, 2003
  3. Alexander Staubo

    Portable, generic, graceful termination

    Alexander Staubo, Sep 28, 2004, in forum: Python
    Replies:
    0
    Views:
    305
    Alexander Staubo
    Sep 28, 2004
  4. Author Tarun Tyagi
    Replies:
    0
    Views:
    753
    Author Tarun Tyagi
    Dec 29, 2004
  5. joshc
    Replies:
    5
    Views:
    593
    Keith Thompson
    Mar 31, 2005
Loading...

Share This Page