Re: C++ Problems BIS

Posted by Rod Pienaar on
URL: http://quantlib.414.s1.nabble.com/C-Problems-BIS-tp2463p2467.html

I found an excellent posting on Google that discusses this at length.  Have a look its an interesting read.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=EzwT5.39687%241c.580162%40e420r-sjo2.usenetserver.com&rnum=2

Rgds
Rod



                                                                                                                                       
                      Rod Pienaar                                                                                                      
                                               To:      [hidden email]                                          
                      11/04/2003 13:48         cc:                                                                                    
                                               Subject: Re: [Quantlib-users] C++ Problems BIS(Document link: Rod Pienaar)              
                                                                                                                                       



I have never written my own code for this but I extracted the following information from the Borland help file.  They talk about creating error handers based on custom defined _matherr or _matherrl.  I hope that I have not contravened any of their copyright laws by posting this.  I hope it helps.

_matherr and _matherrl are useful for information on trapping domain and range errors caused by the math functions. They do not trap floating-point exceptions, such as division by zero. See signal for information on trapping such errors.  You can define your own _matherr or _matherrl routine to be a custom error handler (such as one that catches and resolves certain types of errors); this customized function overrides the default version in the C library. The customized _matherr or _matherrl should return 0 if it fails to resolve the error, or nonzero if the error is resolved. When _matherr or _matherrl return nonzero, no error message is printed and the global variable errno is not changed.




                                                                                                                                                     
                      [hidden email]                                                                                                          
                      Sent by:                               To:       [hidden email]                                          
                      [hidden email]        cc:                                                                                    
                      ceforge.net                            Subject:  [Quantlib-users] C++ Problems BIS                                            
                                                                                                                                                     
                                                                                                                                                     
                      11/04/2003 13:27                                                                                                              
                                                                                                                                                     
                                                                                                                                                     





Hi,

just a little C++ question...

how can I catch mathematical exceptions?

I mean, if I compute log(-1), result is -#IND.0000 (or something like
this).

I would like an exception to be thrown and catched in my exception handler.
I can check "errno" after every calculation but it is not so pretty...

any idea?



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Quantlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users







--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.