Order of operators by the priority

The priority of operators within each of the listed categories rises from left to right. Priority of the whole operator category rises from the bottom to the top.

|, & , !
>, <, >=, <=, =, #
+, -, *, /

It is important to realize, that the priority of the operators +, - or *, / is not the same. Mainly different priorities of multiplication and division may cause incorrect results in the integer logic. For example, the result of the integer expression 25*50 / 900 is 0 because as the first the division is performed, and then the multiplication. The correct result is evaluated after the modification of the expression to the form: (25*50) / 900.

Napíšte komentár