The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
108 views

Order of Operations Annoyance [duplicate]

In most programming languages (C#, JavaScript, Java) the order of operations precedence has that equality comparison come BEFORE bitwise comparisons. This means that if you have a bit operation and ...
2
votes
0answers
106 views

Programmatically manipulate expressions accounting for operator precedance [closed]

There are times when an expression becomes confusing because of implicit operator precedence. Take this Python expression: a, b, c, d = range(4) e = a + b // c << d >> a ** b or a + c * ...
1
vote
2answers
334 views

Should ** bind more tightly than !, ~?

Designing a programming language, I'm including the ** exponentiation operator. In Fortran and Python, the two languages I know of which have this operator, it binds more tightly than unary minus, ...
62
votes
15answers
7k 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
135 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 ','). ...
37
votes
2answers
2k 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 (&, |, ...