Operator precedence: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: bar unary ops) |
(Operator precedence en FreeBASIC) |
||
Line 911: | Line 911: | ||
|| Start and End of an expression || |
|| Start and End of an expression || |
||
|} |
|} |
||
=={{header|FreeBASIC}}== |
|||
If operators have equal precedence, they then are evaluated in the order in of their associativity. The associativity may be Left-to-Right or Right-to-Left order. |
|||
As a rule, binary operators (such as +, ^) and unary postfix operators (such as (), ->) are evaluated Left-to-Right, and unary prefix operators (such as Not, @) are evaluated Right-to-Left. |
|||
Operators that have an associativity of "N/A" indicate that there is no expression in which the operator can be used where its order of operation would need to be checked, either by precedence or by associativity. Function-like operators such as Cast are always the first to be evaluated due to the parentheses required in their syntax. And assignment operators are always the last to be evaluated. |
|||
Parentheses can be used to override operator precedence. Operations within parentheses are performed before other operations |
|||
{| class="wikitable" |
|||
! Priority || Operator || Description || Associativity |
|||
|- |
|||
| ALIGN=CENTER|highest || CAST ||Type Conversion || N/A |
|||
|- |
|||
| ALIGN=CENTER|highest || PROCPTR ||Procedure pointer || N/A |
|||
|- |
|||
| ALIGN=CENTER|highest || STRPTR ||String pointer || N/A |
|||
|- |
|||
| ALIGN=CENTER|highest || VARPTR ||Variable pointer || N/A |
|||
|- |
|||
| ALIGN=CENTER|18 || [] ||String index || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|18 || [] ||Pointer index || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|18 || () ||Array index || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|18 || () ||Pointer to member access || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|18 || . ||Member access || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|18 || -> ||Pointer to member access || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|17 || @ ||Address of || Right-to-Left |
|||
|- |
|||
| ALIGN=CENTER|17 || * ||Value of || Right-to-Left |
|||
|- |
|||
| ALIGN=CENTER|17 || New ||Allocate Memory || Right-to-Left |
|||
|- |
|||
| ALIGN=CENTER|17 || Delete ||Deallocate Memory || Right-to-Left |
|||
|- |
|||
| ALIGN=CENTER|16 || ^ ||Exponentiate || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|15 || - ||Negate || Right-to-Left |
|||
|- |
|||
| ALIGN=CENTER|14 || * ||Multiply || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|14 || / ||Divide || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|13 || \ ||Integer divide || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|12 || MOD ||Modulus || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|11 || SHL ||Shift left || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|11 || SHR ||Shift right || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|10 || + ||Add || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER|10 || - ||Subtract || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 9 || & ||String concatenation || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 8 || Is ||Run-time type information check || N/A |
|||
|- |
|||
| ALIGN=CENTER| 7 || = ||Equal || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 7 || <> ||Not equal || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 7 || < ||Less than || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 7 || <= ||Less than or equal || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 7 || >= ||Greater than or equal || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 7 || > ||Greater than || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 6 || NOT ||Complement || Right-to-Left |
|||
|- |
|||
| ALIGN=CENTER| 5 || AND ||Conjunction || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 4 || OR ||Inclusive Disjunction || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 3 || EQV ||Equivalence || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 3 || IMP ||Implication || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 3 || XOR ||Exclusive Disjunction || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 2 || ANDALSO ||Short Circuit Conjunction || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 2 || ORELSE ||Short Circuit Inclusive Disjunction || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 1 || =[>] ||Assignment || Left-to-Right |
|||
|- |
|||
| ALIGN=CENTER| 1 || &= ||Concatenate and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || += ||Add and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || -= ||Subtract and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || *= ||Multiply and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || /= ||Divide and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || \= ||Integer Divide and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || ^= ||Exponentiate and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || MOD= ||Modulus and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || AND= ||Conjunction and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || EQV= ||Equivalence and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || IMP= ||Implication and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || OR= ||Inclusive Disjunction and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || XOR= ||Exclusive Disjunction and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || SHL= ||Shift Left and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || SHR= ||Shift Right and Assign || N/A |
|||
|- |
|||
| ALIGN=CENTER| 1 || LET ||Assignment || N/A |
|||
|- |
|||
| ALIGN=CENTER|lowest || LET() ||Assignment || N/A |
|||
|} |
|||
=={{header|Furor}}== |
=={{header|Furor}}== |