Calculating priority and type conversion

Calculating priority and type conversion

 

 

 

1. In an expression may contain a plurality of different operators connected together, the data having different types of data objects; operation because a variety of expression, different combinations may have different results even order error calculation error, because when the expression contains a variety of operations, it must be combined in a certain order, in order to ensure the reasonableness and accuracy of the results, the uniqueness of operations.

Descending order of priority from top to bottom, the top has the highest priority, the comma operator has the lowest priority. Expression depends on the priority order of the combined expression of various operators. A higher priority operator to binding, binding to low priority operators, the same operators in the same row of the priority .

 

 

 

 

 

 

 

 

 

 

2. priority regardless of the order of evaluation. As a + b && b * c, * while the highest priority, but this expression is evaluated from left to right order.

Descending order of priority from top to bottom, the top has the highest priority, the comma operator has the lowest priority.

The same priority level, by binding binding. Most operators left to right binding, only three priority right to left binding, are unary operators, conditional operators , assignment operators .

The basic priorities need to remember:

Optimal pointer, unary than binary operator. The sign.

First arithmetic, shift operation after the last bit computing. To note: 1 + 2 & 3 << 7 is equivalent to (1 << (3 + 2)) & 7.

Finally, the logic operation.

 

Guess you like

Origin www.cnblogs.com/yhakaki/p/11516648.html