Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-08-03 16:08:23

On Thu, 3 Aug 2006 19:14:19 +0100, "John Maddock"
<john_at_[hidden]> wrote:

>Apparently this was not quite as simple as I thought it was, because we
>still need to handle the 0/0 case, the following patch does the trick:

Sorry to jump in at the latest moment. I wasn't following this thread
(it's interesting, but time is limited :-()

>cvs diff: Diffing boost/test
>Index: boost/test/floating_point_comparison.hpp
> }
>+ else if(f1 == 0)
>+ {
>+ // Avoid 0 / 0, since we're calculating relative error

Shouldn't the comment read 0/x or 0/anything?

>+ // the result really is zero here no matter what the denominator:

Unless the denominator is zero, in which case returning zero is a

>+ return 0;
>+ }
>+ else if(f2 == 0)
>+ {
>+ // We have an infinite relative error, in practice any
>+ // big number returned here will cause our test to fail:
>+ return 1000000; // any really big number will do.

Could you please clarify the context a bit? Would this, in general, be
called also when numeric_limits is not specialized? When a
specialization exists I would return (std::numeric_limits<>::max)();
when it doesn't, how can one be sure that an FPT can be constructed
from the integer 1000000? Sorry if this is just noise; I just thought
better *I* raise some noise now than some executable somewhere will do
it later :-)

[ Gennaro Prota, C++ developer for hire ]

Boost list run by bdawes at, gregod at, cpdaniel at, john at