I have an "if" statement that looks for doubles being equal:

if(Low[1] == LowPivotOne)

where: LowPivotOne is a double

LowPivotOne is set via: LowPivotOne = Low[1];

Essentially this is checking to see if the current Low[1] is equal to the previous low pivot.

Problem is, this method is random. Sometimes it works and other times it doesn't. I've searched on this problem and learned that comparing doubles for equality is problematic. This is because doubles are not stored as precise numbers and will have small offsets.

I've tried Convert.To.Decimal but that started getting out of hand. I had to continually convert more and more variables and it just didn't seem the most elegant solution.

Is there a fairly simple way to compare two doubles for equality in an If statement?

regards,
taddypole...