Features of the mql5 language, subtleties and tricks - page 288

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
If we proceed from the task " how to make equal faster"...
Then we should reduce possible conventions and operations.
In my opinion switch will be the fastest at the level of assembly registers.
And the remainder from division is an expensive operation.
That's what Renat wrote.
Note that I have not said a word about the usefulness of your variant, use whatever you want. After all, I am not imposing anything on anyone.
You could talk about execution speeds on Pentium computers or earlier...
Note, I have not said a word about the usefulness of your option, use whatever you want. After all, I am not imposing anything on anyone.
You could talk about execution speeds on Pentium computers or earlier...
It seems we share our view, without pretensions to uniqueness.
And imposition is out of the question.
Strange and not clear your position, immediately into the rack ))
In my opinion switch, will be the fastest at the assembly register level.
I assume that the XOR variant is faster.
I assume the XOR variant is faster.
Hm...
Indeed, you get one operation, no branching.
switch is redundant.
Hm...
Indeed, you get one operation, no branching.
switch is redundant.
but switch is more correct. Int toggle_value(int &x) { return x=x^1; } is beaten for optimisation. Because the optimisation is miserable, and when 'x' has the 3rd allowed value (it will be int, too), a hard-to-find glitch will appear in the project.
so either switch or x must be bool.
Example?
Example?