Login  Register

Rif: Re: C++ Problems BIS

Posted by andrea.odetti-2 on Apr 11, 2003; 7:39am
URL: http://quantlib.414.s1.nabble.com/Rif-Re-C-Problems-BIS-tp2469.html

>Andrea,
>you're lucky. On at least one platform (I don't remember which)

>when I happened to divide by zero, my programs completely crashed...

I don't know which one is better...


>The only _portable_ way I can think of for avoiding this is to be defensive
>and instead of:

>double foo(double x, double y) {
>return log(x)/y;

>}

>write:

>double foo(double x, double y) {
>QL_REQUIRE(x > 0.0, "negative log argument");
>QL_REQUIRE(y != 0.0, "division by zero");
>return log(x)/y;

>}

uhm... I don't want to rewrite all amth functions...

thanks

andrea