add ^
This commit is contained in:
@@ -114,6 +114,8 @@ double Calculator::evaluate(std::string equation, std::unordered_map<char, std::
|
|||||||
return std::stod(equation);
|
return std::stod(equation);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//op is now the appropriate operator
|
//op is now the appropriate operator
|
||||||
@@ -146,6 +148,8 @@ double Calculator::evaluate(std::string equation, std::unordered_map<char, std::
|
|||||||
return a + b;
|
return a + b;
|
||||||
case '-':
|
case '-':
|
||||||
return a - b;
|
return a - b;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +159,12 @@ std::string Calculator::calculate(std::string equation) {
|
|||||||
while(equation.find(' ') != std::string::npos) {
|
while(equation.find(' ') != std::string::npos) {
|
||||||
equation.erase(equation.find(' '), 1);
|
equation.erase(equation.find(' '), 1);
|
||||||
}
|
}
|
||||||
|
while(equation.find('\t') != std::string::npos) {
|
||||||
|
equation.erase(equation.find('\t'), 1);
|
||||||
|
}
|
||||||
|
while(equation.find('\n') != std::string::npos) {
|
||||||
|
equation.erase(equation.find('\n'), 1);
|
||||||
|
}
|
||||||
|
|
||||||
std::unordered_map<unsigned int, std::string> nodes;
|
std::unordered_map<unsigned int, std::string> nodes;
|
||||||
std::unordered_map<char, std::string> evalStr;
|
std::unordered_map<char, std::string> evalStr;
|
||||||
@@ -257,19 +267,16 @@ void Calculator::basicCalculator() {
|
|||||||
s.clear();
|
s.clear();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("()")) {
|
if(ImGui::Button("(")) {
|
||||||
|
s += " ( ";
|
||||||
if(parenthesis) {
|
|
||||||
s += " ( ";
|
|
||||||
} else {
|
|
||||||
s += " ) ";
|
|
||||||
}
|
|
||||||
|
|
||||||
parenthesis = !parenthesis;
|
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("Gr")) {
|
if(ImGui::Button(")")) {
|
||||||
graphing = true;
|
s += " ) ";
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if(ImGui::Button("^")) {
|
||||||
|
s += " ^ ";
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("=")) {
|
if(ImGui::Button("=")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user