Rif: Re: C++ Problems BIS

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Rif: Re: C++ Problems BIS

andrea.odetti-2

>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