Are System.Double operators overloaded for epsilon?

  • Thread starter Thread starter David Veeneman
  • Start date Start date
D

David Veeneman

Are System.Double operators overloaded to perform epsilon comparisons, or do
these comparisons have to be performed by the programmer. In other words, if
I have two doubles, A and B, and I test "A > B", does C# do a strict
mathematical comparison, or does it do a "A - B > Double.Epsilon"
comparison? Thanks
 
David,

I don't believe that epsilon is used in comparisons. If you need to
assure a degree of precision, then use the Decimal class, which will
guarantee precision (and therefore, remove the need for epsilons).

Hope this helps.
 
David,

I believe the equality comparison is based on the binary pattern of the
operands, except for special cases (NaN).
It is programmer's responsibility to check against an Epsilon instead of
using '==' on floating point values.

Regards - Octavio
 
Nicholas Paldino said:
I don't believe that epsilon is used in comparisons. If you need to
assure a degree of precision, then use the Decimal class, which will
guarantee precision (and therefore, remove the need for epsilons).

Decimal doesn't guarantee precision - it certainly doesn't prevent
rounding errors etc. It just changes the set of numbers which can be
exactly represented.
 
They are not. IMO it's a good thing that they aren't since that would
be counter-intuitive, but I certainly would applaud an additional set
of standard methods to perform epsilon comparisons on floats &
doubles. I asked David Notario but I don't think he'll do it. :)
 
Back
Top