i'm sorry i was out of network.

i'm sorry to both, but i never worked with tokers and i must learn how to use them(i must go from the start).

but i can share these code that now works with minus too:

these is the basic of basic for what we can do for convert 1 string to Math Expression.Code:class MathOperators{ public: enum enumMathOperators { ParenthesesOpen='(', ParenthesesClose=')', Add='+', Minus='-', Multiplication ='*', Space=' ', Division ='/' }; static bool IsMathOperator(char enMath) { switch(enMath) { case ParenthesesOpen: case ParenthesesClose: case Add: case Minus: case Multiplication: case Space: case Division: return true; default: return false; } } }; bool IsNumeric(string strValue) { for(unsigned int i=0; i<strValue.size() ; i++) { if(!isdigit(strValue[i])) return false; } return true; } void CalculateExpression(string strMathExpression) { //clean empty spaces for(unsigned int i=0; i<strMathExpression.size(); i++) { if(strMathExpression[i]== ' ' || strMathExpression[i]== '\t') { strMathExpression.erase(i,1); i=0; } } //spare the operator and numbers //for add them on a vector: string strNumber=""; vector<string> vecOperator; int OperatorCount=0; //we must add a null string terminator //for we convert the char to string //or we can get unexpected results: char chr[]={'0','\0'}; for(unsigned int i=0; i<=strMathExpression.size() ; i++) { chr[0]=strMathExpression[i]; if((chr[0]=='-' && strMathExpression[i-1]=='-')) { vecOperator[vecOperator.size()-1]='+'; OperatorCount++; continue; } else if((chr[0]=='-' && strMathExpression[i-1]=='+')) { vecOperator[vecOperator.size()-1]='-'; OperatorCount++; continue; } else if((chr[0]=='+' && strMathExpression[i-1]=='-')) { vecOperator[vecOperator.size()-1]='-'; OperatorCount++; continue; } else if((chr[0]=='+' && strMathExpression[i-1]=='+')) { vecOperator[vecOperator.size()-1]='+'; OperatorCount++; continue; } if(isdigit(chr[0]) || chr[0]=='.') { strNumber+=chr[0]; } else { if(isdigit(strNumber[0])) vecOperator.push_back(strNumber); if( MathOperators::IsMathOperator(chr[0])==true) { vecOperator.push_back(chr); OperatorCount++; } OperatorCount++; strNumber=""; } } //print actual vector: for (unsigned int a=0; a<vecOperator.size();a++) { cout << vecOperator[a] << " "; } cout << "\n"; //making the math: for(unsigned int i=0;i<vecOperator.size(); i++) { double result=0.0f; //test the math order: for(unsigned int a=0;a<vecOperator.size(); a++) { if(vecOperator[a]=="*" || vecOperator[a]=="/" ) { i=a; break; } } if(vecOperator[i]=="+") { //get result in int: result=stof(vecOperator[i-1])+ stof(vecOperator[i+1]); string strResult=to_string(result); //erase all zeros after the dot //if the dot don't show any zero, is deleted too: for(unsigned int intResult=(strResult.size()-1); intResult>0; --intResult) { if(strResult[intResult]=='0' && strResult[intResult-1]=='.') { strResult.erase(intResult,1); //strResult.erase(intResult-1,1); strResult[intResult-1]='\0'; break; } else if(strResult[intResult]=='0') { //strResult.erase(intResult,1); strResult[intResult]='\0'; } else { break; } } //get the result in int to string: vecOperator[i-1]= strResult; //erase the next 2 elements: vecOperator.erase(vecOperator.begin()+i,vecOperator.begin()+i+2); //print the elements after changes: for (unsigned int a=0; a<vecOperator.size();a++) { cout << vecOperator[a] << " "; } cout << "\n"; //before continue the i must be -1 //when the for restart, the i will be 0: i=-1; continue; } else if(vecOperator[i]=="-") { result=stof(vecOperator[i-1])- stof(vecOperator[i+1]); string strResult=to_string(result); for(unsigned int intResult=(strResult.size()-1); intResult>0; --intResult) { if(strResult[intResult]=='0' && strResult[intResult-1]=='.') { strResult.erase(intResult,1); strResult.erase(intResult-1,1); break; } else if(strResult[intResult]=='0') { strResult.erase(intResult,1); } else { break; } } //get the result in int to string: vecOperator[i-1]= strResult; vecOperator.erase(vecOperator.begin()+i,vecOperator.begin()+i+2); for (unsigned int a=0; a<vecOperator.size();a++) { cout << vecOperator[a] << " "; } cout << "\n"; i=-1; continue; } else if(vecOperator[i]=="/") { result=stof(vecOperator[i-1])/ stof(vecOperator[i+1]); string strResult=to_string(result); for(unsigned int intResult=(strResult.size()-1); intResult>0; --intResult) { if(strResult[intResult]=='0' && strResult[intResult-1]=='.') { strResult.erase(intResult,1); strResult.erase(intResult-1,1); break; } else if(strResult[intResult]=='0') { strResult.erase(intResult,1); } else { break; } } //get the result in int to string: vecOperator[i-1]= strResult; vecOperator.erase(vecOperator.begin()+i,vecOperator.begin()+i+2); for (unsigned int a=0; a<vecOperator.size();a++) { cout << vecOperator[a] << " "; } cout << "\n"; i=-1; continue; } else if(vecOperator[i]=="*") { result=stof(vecOperator[i-1])* stof(vecOperator[i+1]); string strResult=to_string(result); for(unsigned int intResult=(strResult.size()-1); intResult>0; --intResult) { if(strResult[intResult]=='0' && strResult[intResult-1]=='.') { strResult.erase(intResult,1); strResult.erase(intResult-1,1); break; } else if(strResult[intResult]=='0') { strResult.erase(intResult,1); } else { break; } } //get the result in int to string: vecOperator[i-1]= strResult; vecOperator.erase(vecOperator.begin()+i,vecOperator.begin()+i+2); for (unsigned int a=0; a<vecOperator.size();a++) { cout << vecOperator[a] << " "; } cout << "\n"; i=-1; continue; } } }

my code is limited, because don't test the errors.

if i add: 4-5+6--7(isn't so good adding minus without parentheses, but it's ok for now).

heres the print:

4 - 5 + 6 + 7

-1 + 6 + 7

5 + 7

12

yes you have another question: why that big empty space between '5' and '+'!?! i'm sorry, for now, i don't know why.

but works...

see the next:

3+5-6*7+8-9*2

output:

3 + 5 - 6 * 7 + 8 - 9 * 2

3 + 5 - 42 + 8 - 9 * 2

3 + 5 - 42 + 8 - 18

8 - 42 + 8 - 18

-34 + 8 - 18

-26 - 18

-44

like you see the math order is correct.

the only error is the big empty space. maybe with time i can fix that and add parentheses working.

but, i'm sorry, let me ask: what is the big difference between my code and Tokers?

to be honest i did an array of a string, i think.... i think... the tokers start with these method too