A truly amazing result!!! - page 2

 

Refer to the documentation Priorities and order of operations:

Each group of operations in the table has the same priority. The higher the priority of a group of operations, the higher it is placed in the table. The order of execution determines the grouping of operations and operands.

() Function call from left to right
[] Array element selection
!      Logical negation Right to left
- Sign change
++ Increase by one (increment)
--Decrease by one (decrement)
~ Bitwise negation (complement)
& Bitwise AND operation Left to right
| Bitwise OR
Bitwise exclusive OR (eXclude OR)
<< Left shift
>> Shift to the right
* Multiplication Left to Right
/ Divide
% Modulo division
+ Adding Left to Right
- Subtraction
<= Less than Left to Right
<= Less than or equal to
>= Greater than
>= Greater or equal
== Equal
!= Not equal
|| OR logical operation Left to right
&& Boolean operation AND Left to right
== Assignment Right to Left
+= Addition and Assignment
= Subtraction with assignment
*= Multiply with Assignment
/= Division with assignment
%= Modulo division with assignment
>>= Right shift with assignment
<<= Left shift with assignment
&= Assigned Bitwise AND
|= Bitwise OR and assignment
^= Excluding OR with assignment
comma Left to right

Parentheses are used to change the operation's execution order, and have the highest priority.


Attention: The priority of operations in MQL4 differs slightly from that in C.


So it's true


 

LOL


Compile in C from run if you are too lazy to check.


The compiler is a hundred percent GLUCK.

 

OH, THE SKIES!

AND THE GLITCH IS IN THE C, AND WE THOUGHT.... WHY THERE'S A CRISIS ON THE PLANET.

 

You live and learn. I have always believed that you execute AND first, and then OR. And with this understanding, all the programs worked well. Even very complicated logic combinations.

But here...

No, you'd better not read the forums. They confuse everything.

Programs worked fine.... now they're gonna be glitchy... :))))))))

 
Rosh, wow is that right... There's no such thing in maths or other languages, but in MQL4 it's true? Then it's a glitch in developers' brains :) Sorry...
 
rid >> :

Not at all ! The "or"(||) takes precedence here - unequivocally !

If there are no parentheses, then || will be executed first, and then &&

This is why brackets must be in appropriate places.


However...

   bool a = false, 
      b = true, 
      c = false;
   
   bool res = a || b && c;
   Print( res);               // 1 !
tin
 
... and here... just put brackets, put brackets, put brackets, gentlemen! No problem. And the program will be easier to understand. No one has ever promised that MQL4 = C++/.
 
There is a standard and it must be adhered to. And if the developers produce their own standard which contradicts the generally accepted one, then... dirt is... rubbish.
 

checked the first post in matcad. The answer is 1 0 1 1

Here is the code

 

To be honest, I've never memorised the priority of logical and bitwise operations. Due to innate laziness I just put brackets in the right places.

"There is much, friend Horace...."

Reason: