This project has moved. For the latest updates, please go here.

Complex.IComparable<Complex>

Jun 28, 2009 at 12:15 PM

Hi,

Do we want the Complex class to implement IComparable?

Iridium has a comment "Since there is no canonical order among the complex numbers, Complex does not implement IComparable", but the complex class does implement IComparable.  dnA does not for the reason given in the Iridium comment. 

I think we shouldn't, but we should include the Iridium Comparer classes.

Thanks,

Marcus

Coordinator
Jun 28, 2009 at 1:46 PM

Hi,

Yes. The IComparer<T> interface seems to be better supported than the Comparison<T> delegate. Hence, providing comparer classes for common orderings would be nice.

Contra IComparable<T>:

  • No canonical ordering
  • Avoid confusion

Pro IComparable<T>:

  • Real-only complex numbers behave and can be treated like real (double) numbers.
  • IComparer<T> is not always supported (but it should be).
  • We could override the comparison operators. All in all somewhat easier to use in the default case.

I agree, providing only the comparer classes might be cleaner.

Thanks,
Chris

Marked as answer by cdrnet on 10/3/2013 at 5:34 PM