[std-interval] Interval comparison operators

Ron Avitzur avitzur at PacificT.com
Thu Apr 27 11:33:37 PDT 2006


>But how does the "filtering" function knows that the det2() wasn't 
>computed robustly without exceptions?
>det2() just can't return sign_t anymore.
>
>A solution, which is the one that CGAL uses, could be:
>
>template< class T >
>interval<sign_t> det2(T a, T b, T c, T d)
>{
>  T u = a * d, v = b * c;
>   if (certainly(u < v) ) return negative;
>   if (certainly(u > v) ) return positive;
>   if (certainly(u == v) ) return zero ;
>   return interval<sign_t>::empty();
>}
>So, without a throwing conversion to bool, the proposal must 
>incorporate interval<E> for all discrete types besides bool in order 
>to let the user actually get away without exceptions.

It is not clear from this example that interval<E> is required for discrete
types. All that is required is that det2 return an error, somehow. It may
throw an exception (explicitly or implicitly via an interval operator),
or it may return a separate error code in a parameter, or it may use an
enum type including {negative, positive, zero, and error}.

The question at hand is whether the interval library should throw
that exception itself. As long as one is explicitly considering the
interval cases, one could as easily write, for example:

  if (certainly(u < v) ) return negative;
  if (certainly(u > v) ) return positive;
  if (certainly(u == v) ) return zero ;
  throw (interval_comparison_exception); // or return error;

It is a tradeoff between being able to write concise code and requiring
one to write more explicitly what is intended in interval cases.

By the way, if anyone on the list would like a copy of our software
to play with (Mac or Windows), send me an e-mail privately.
  http://PacificT.com/Examples/ExampleB6.html

- Ron Avitzur



More information about the Std-interval mailing list