#define swap(a,b) {a=a+b;b=a-b;a=a-b;}
fxsaber:
Thank you.
Also, sorting three numbers:
#define SORT(a,b,c) {(a > b) ? SWAP(a,b) : ((a > c) ? SWAP(a,c) : ((b>c) : SWAP(b,c)))}
Arthur Albano:
Also, sorting three numbers:
Such designs are impossible.
fxsaber:
Such designs are impossible.
#define SORT(a,b,c) {if(a > b) SWAP(a,b); if(a > c) { SWAP(a,c) }; if (b>c) { SWAP(b,c) }}
Yes, it works.
#define SWAP(A, B) { A += B; B = A - B; A -= B; } #define SORT(a,b,c) {if(a > b) SWAP(a,b) if(a > c) SWAP(a,c) if (b>c) SWAP(b,c) }
fxsaber:
Yes, it works.
Yes, it works.
I like semicolons because it improves readability :P But thanks!
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Особенности языка mql5, тонкости и приёмы работы
fxsaber, 2018.08.26 19:28
#define SWAP(A, B) { A ^= B; B ^= A; A ^= B; }
#define SWAP(A, B) A ^= (B ^= (A ^= B));
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
Hi!
In C programming language, one way to swap numbers is:
#define swap(a,b) (a=a+b;b=a-b;a=a-b;)
How can we write this in MQL5?