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
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.