The problem with understanding what to do with the output of the bypass algorithm

I watched the wiki page: http://en.wikipedia.org/wiki/Shunting-yard_algorithm

I used the sample code to build the first part, basically I can now:

3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 at 3 4 2 * 1 5 − 2 3 ^ ^ / +

But I do not know how to use 3 4 2 * 1 5 − 2 3 ^ ^ / +to receive3.00012207

Both the sample code and the explanation on the wiki make no sense to me.

Can someone explain how to evaluate 3 4 2 * 1 5 − 2 3 ^ ^ / +and give an answer. Thanks in advance. I don't need sample code, just a good explanation or breakdown of the example.

Not important, but I am running .net C #.

+5
source share
4 answers

, Reverse Polish Notation, :

  • :
    • ,
    • ; - , ,
  • , , ; .
+9

- , , , HP.

, , , . , , ,

token stack
      *empty*
 3    3         //push numbers...
 4    3 4
 2    3 4 2
 *    3 8       //remove 4 and 2, add 4*2=8
 1    3 8 1
 5    3 8 1 5
 -    3 8 -4
 2    3 8 -4 2
 3    3 8 -4 2 3
 ^    3 8 -4 8
 ...    ...
+8

3 4 2 * 1 5 − 2 3 ^ ^ / + :

  • .
  • , .
  • , , .

, , .

+2

, .

, Rosetta Code. , , . , RPN, .

:

For RPN expression: '3 4 2 * 1 5 - 2 3 ^ ^ / +'

TOKEN           ACTION                 STACK      
3     Push num onto top of stack 3                
4     Push num onto top of stack 3 4              
2     Push num onto top of stack 3 4 2            
*     Apply op to top of stack   3 8              
1     Push num onto top of stack 3 8 1            
5     Push num onto top of stack 3 8 1 5          
-     Apply op to top of stack   3 8 -4           
2     Push num onto top of stack 3 8 -4 2         
3     Push num onto top of stack 3 8 -4 2 3       
^     Apply op to top of stack   3 8 -4 8         
^     Apply op to top of stack   3 8 65536        
/     Apply op to top of stack   3 0.0001220703125
+     Apply op to top of stack   3.0001220703125  

 The final output value is: '3.0001220703125'
+2
source

All Articles