The operator-precedence tag has no wiki summary.
0
votes
1answer
54 views
Undefined behaviour or precedence question [duplicate]
The following code snippet in C:
i=i++;
has undefined behaviour according to a book.But my logic is this:
Since ++ operator has more precedence than = operator,it should be evaluated first,so i++ ...
57
votes
15answers
4k views
Should I use parentheses in logical statements even where not necessary?
Let's say I have a boolean condition a AND b OR c AND d and I'm using a language where AND has a higher order of operation precedent than OR. I could write this line of code:
If (a AND b) OR (c AND ...
2
votes
1answer
85 views
Evaluation order of the expressions
The C Programming Language by K & R states that C, like most languages, does not specify the order in which operands of an operator are evaluated. (The exceptions are &&,||,?: and ','). ...
33
votes
2answers
1k views
Why do bitwise operators have lower priority than comparisons?
Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...