Boost logo

Boost :

From: Guillaume Melquiond (gmelquio_at_[hidden])
Date: 2002-09-06 12:03:09


On 6 Sep 2002, Gabriel Dos Reis wrote:

> | The issue is that when x or y is a nan, comparisons involving a nan
> | always return false (except != which returns true).
> |
> | The issue came up when I asked Guillaume why checking_base::is_empty
> | returns !(l <= u) and not (u < l). For representing empty intervals, we
> | allow checking_base to use nan (if T has a quiet nan), or to use [1,0]
> | otherwise. So the first test !(l <= u) always works no matter whether T
> | has quiet nans or not, whereas the second will not work if T has quiet
> | nans.
>
> Well, I'm not sure using NaN is a wise choice here. It adds more
> confusion that it should. I'm not convinced that a NaN should be
> used to represent an ympty interval.

The test is '!(l <= u)' and not '(u < l)' because the property we expect
is 'l <= u'. So it allows to correctly handle partial orders. And the NaNs
are only a particular example of that.

Concerning the empty intervals, when std::numeric_limits<T> says that the
type possesses quiet NaNs, they are used; otherwise, the empty interval is
[T(1); T(0)]. But it's only an implementation detail and it doesn't impact
the interface. Moreover, it's only for the default policy; the user can
provide its own policy.

Regards,

Guillaume


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk