MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / doNextOperation

Method doNextOperation

src/MathExp.cpp:95–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void MathExp::doNextOperation()
96{
97 //pop operator off and apply it, then push the value onto the operand stack
98 const char top = mOperators.top();
99 float val = 0;
100
101 if(top == *"+")
102 {
103 val = mOperands.top();
104 mOperands.pop();
105 val += mOperands.top();
106 mOperands.pop();
107 }
108 if(top == *"-")
109 {
110 val = mOperands.top();
111 mOperands.pop();
112 val = mOperands.top() - val;
113 mOperands.pop();
114 }
115 if(top == *"*")
116 {
117 val = mOperands.top();
118 mOperands.pop();
119 val *= mOperands.top();
120 mOperands.pop();
121 }
122 if(top == *"/")
123 {
124 val = mOperands.top();
125 mOperands.pop();
126 val = mOperands.top() / val;
127 mOperands.pop();
128 }
129
130 mOperands.push(val);
131
132 mOperators.pop();
133}
134
135void MathExp::setExpression(std::string str)
136{

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected