Boost logo

Boost :

From: Herve Bronnimann (hbr_at_[hidden])
Date: 2002-09-06 11:19:28


On Fri, Sep 06, 2002 at 11:14:09AM -0400, David Bergman wrote:
> > Having operator<= that is !> is important if you want to prevent user
> > mistakes, such as replacing
> > if(!(x < y))
> > with
> > if(y >= x)

I assume you meant (y <= x).

> I argue that the user should be aware that he is dealing with a
> partial order (if the order is such, such as '<' being subset) when
> coding, so, yes, he might be forced to change the logic (in this case
> control flow) when going from a total to a partial order...

By the way and for the record, one thing I learned during our
discussions (Sylvain, Guillaume and I) when preparing the submission,
was that !(x < y) and (y <= x) are almost always but not absolutely
equivalent, even for double which has a total order. I think it's a
lesson worth sharing.

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.

So even for the type double, simple equivalences like !> := <= are to be
taken with a grain of salt because they are not always true...

-- 
Herve'

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