Quantcast
Channel: User Federico klez Culloca - Stack Overflow
Viewing all articles
Browse latest Browse all 505

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

$
0
0

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 all articles
Browse latest Browse all 505

Trending Articles



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