Quantcast
Viewing latest article 2
Browse Latest Browse All 484

Answer by Federico klez Culloca for postfix evaluation calculated result is wrong

char token = expr.charAt(index); returns '3' on the first iteration, but that's a char representing the character '3' (i.e. 51), not the number 3.

To use the number instead of the character representing that number you can push it into the stack by subtracting '0' from it, like this:

stack.push(operandIn - '0');

Viewing latest article 2
Browse Latest Browse All 484

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>