Questions tagged [expression-evaluation]

Anything related to expression evaluation, i.e. the process of determining the value of an expression in running code.

Anything related to expression evaluation, i.e. the process of determining the value of an expression in running code.

189 questions
-1
votes
2 answers

Evaluate expression for specific requirement in java

I have Expression object which has the following: Operator parameter value Each simple Expression mentioned can be combined into a compound expression. public SimpleExpresssion createcompound(SimpleExpression simple1,SimpleExpression simple2) …
Amarendra Reddy
  • 243
  • 2
  • 17
-1
votes
1 answer

how to evaluate of an abstract syntax tree of a new programming languag

i want to design a compiler for a 'new' language.The new language will have it's own syntax and outputs a valid C code.that is, generate a c code from pseudo code.I had designed a grammar.perform recursive descent parsing and got the abstract syntax…
-1
votes
1 answer

Expression evaluation in C++ involving unary operators

Why does not C/C++ evaluates expression in order of left to right in these cases: Initially x=1 Evaluating x + ++x gives 4. If normal evaluation is carried out (precedence of ++ is higher than +) then the result should be 1 + 2 = 3 Similarly: x +…
Rajs123
  • 663
  • 13
  • 30
-2
votes
1 answer

Trying to understand --x vs x-- in C++

I am trying to evaluate this, and even if is is quite simple, I can't seem to understand it. I got 16, but the provided answer was 12. I don't understand how this can be 12. I did --x first, so first y would be 4, then I need to multiply with x--,…
-2
votes
2 answers

How can I evaluate an expression string containing variables?

In Unity I'm trying to make it so you enter an expression and then it outputs a value but I want to use variables like: x = 10 "x + x * 10" ^ outputs 200
-2
votes
1 answer

Java: arithmetic mechanics on a basic level or evaluation strategies

Excuse me for the vagueness of the question, but I'm a relatively new programmer. How exactly does the computer know how to do arithmetic? Does every language - specifically Java, have an add, subtract, addition, subtraction, modular division…
Andrew Lin
  • 13
  • 1
-3
votes
1 answer

Is go evaluation order between member invocations guaranteed?

Let's say I have a struct with state, and a few member functions on that struct. Let's say that the struct member returns an instance of its own type, and I call additional functions on that instance, and pass the result of calling some other member…
Jon Watte
  • 6,579
  • 4
  • 53
  • 63
-3
votes
2 answers

Postfix increment operator evaluation

Are postfix increment/decrement operators evaluated after the expression is evaluated or after the entire statement is evaluated ? #include void main() { int a=0; int b=0; printf("%d %d",a||b,b++); // Output is 1 0 } My compiler…
-4
votes
1 answer

Why is the output of 49/square(7) 49 in C?

Why is the output of 49/square(7) 49 in C? I have a macro defined as #define square(rasna) rasna*rasna. When I use this macro in the expression 49/square(7), the output is 49. However, I expected the output to be 1. Why is this happening? Here is…
1 2 3
12
13