First of all, use operators, not
System.Object.Equal
:
if (ds > ds1)
if (ds >= ds1)
if (ds == ds1)
But be very careful with ==. In most calculations, you should not use this operator. You need to understand that the floating-point types can only provide
approximate representation of mathematical real numbers. The equality should only be considered with certain accuracy. For example, you may need to check up if two values are "close enough":
if (System.Abs(ds - ds1) < delta)
In other cases, you need to operate with
relative accuracy.
—SA