Skip to main content

Questions tagged [operator-precedence]

-3 votes
1 answer
150 views

For instance in the expression a+b*c, applying precedence (grouping) we get a+(b*c) because * has higher precedence than +. Nonetheless, I'm struggling to understand the case in which we'd decide to ...
excitedGoose's user avatar
0 votes
1 answer
397 views

I'm working on a parser for a (very small) toy language, and I want to test that it's parsing expressions with the appropriate precedence. Previously I just had arithmetic operators, so there weren't ...
DylanSp's user avatar
  • 327
6 votes
2 answers
2k views

Absolutely academic context question- I found countless articles listing the order of operator precedence in all languages, but what is the logical reasoning behind that specific order? For clarity ...
Benson's user avatar
  • 79
-2 votes
2 answers
6k views

The facts This is a very similar question to this one, but here I am talking about a more general case the MISRA-C3 Rule 5.0.2 or the SEI CERT C EXP00-C rule (more permissive). Within MISRA-C3 I ...
nowox's user avatar
  • 177
0 votes
2 answers
288 views

I have a code snippet in Java: int y = ++x * 5 / x-- + --x; So my confusion was since x--(postfix) has higher precedence than ++x(prefix) operator so x-- should be executed first then ++x.But a book ...
user1369975's user avatar
  • 1,319
-3 votes
2 answers
216 views

I'm having trouble in figuring out why the output for theses two lines is different .. public static void main(String[] args) { System.out.println("6.0+1="+6.0+1); System.out.println("6.0+1="+(...
lulu's user avatar
  • 1
4 votes
1 answer
4k views

I am attempting to implement a shunting-yard algorithm for a calculator following the rules laid out in https://en.wikipedia.org/wiki/Shunting-yard_algorithm . When programming the unary minus, ...
Industrialactivity's user avatar
9 votes
3 answers
3k views

Actually, in this question I do not ask about particular language or architecture, however I understand there might be some differences. In physics / engineering it is usually better to handle ...
Voitcus's user avatar
  • 201
0 votes
3 answers
249 views

I've seen this example in a text book and am a little confused how to interpret the operator precedence rules. Given this struct: typedef struct { char *data; size_t start, end; } ...
James S.'s user avatar
  • 111
10 votes
3 answers
7k views

I am working through the Shunting-yard algorithm, as described by wikipedia. The description of the algorithm when dealing with operators is as follows: If the token is an operator, o1, then: ...
MirroredFate's user avatar
1 vote
1 answer
182 views

One of our teachers said that there is just one example that there is a difference between (-(a*b)) and ((-a)*b). He said by using two's complement you can find one. I am trying to find this example. ...
TTS's user avatar
  • 31
0 votes
1 answer
363 views

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 ...
CleverPatrick's user avatar
1 vote
2 answers
1k views

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, ...
rwallace's user avatar
  • 1,208
125 votes
15 answers
89k views

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 precedence than OR. I could write this line of code: If (a AND b) OR (c AND d)...
3 votes
1 answer
269 views

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 ','). ...
user1369975's user avatar
  • 1,319

15 30 50 per page