Comparison of floating point variables
Hello.
I try to avoid such situations. I think it is because of the feature of storing doubles. One time you assign 0.01 and get 0.01 in variable. Another time you can get smth like 0.010000001. At least this mechanism exists in C++, and i'm almost sure the same situation is here.
So, compare doubles like
if(d1 - d2 < 0.00001)
Or use CompareDoubles function
Quick question.
For simplicity I've avoided normalizing or converting to strings the Ask and Bid variables on the following grounds.
All I'm doing is moving Ask or Bid into another double variable, then later doing a compare of Ask or Bid against that variable.
No arithmetic operations are done on the variable in the intervening period.
It seems to work fine, but is it safe and reliable?
Regds,
CB.