answer #3 seems to be the best - with x & y as conditions & b as overall result (as for XOR)... with such a tip (^) no any violation of XOR logics was noticed by me in real coding in MQL
The issue lies within the type of operation to be performed.
logical operators "do not" support XOR as a separate type, it is represented with unequal, as shown.
Let me give you an example of arithmetic/bitwise and logical operation:
Here the type is given by the logical operator, interpreting the values A and B as logical "true" and "false" values. Since the "&&" operator is specific to the type "bool".
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
answer #3 seems to be the best - with x & y as conditions & b as overall result (as for XOR)... with such a tip (^) no any violation of XOR logics was noticed by me in real coding in MQL
The issue lies within the type of operation to be performed.
logical operators "do not" support XOR as a separate type, it is represented with unequal, as shown.
Let me give you an example of arithmetic/bitwise and logical operation:
As you can see, the interpretation depends on the type.
So when the code is using logical operators "&&", the result is different to the bitwise/arithmetic approach.
This is an important distinguishment.
XOR = A != B
My mistake in this reply was not to give the types, as I interpreted them to be bool.
In fact, if not specified, mql compiler defaults to type "int", since there is no type giving operator in place. This is different for the statement
Here the type is given by the logical operator, interpreting the values A and B as logical "true" and "false" values. Since the "&&" operator is specific to the type "bool".
ok, I will check_ once again. Thanks