| 1197 | } |
| 1198 | |
| 1199 | std::string MathLib::calculate(const std::string &first, const std::string &second, char action) |
| 1200 | { |
| 1201 | switch (action) { |
| 1202 | case '+': |
| 1203 | return MathLib::add(first, second); |
| 1204 | |
| 1205 | case '-': |
| 1206 | return MathLib::subtract(first, second); |
| 1207 | |
| 1208 | case '*': |
| 1209 | return MathLib::multiply(first, second); |
| 1210 | |
| 1211 | case '/': |
| 1212 | return MathLib::divide(first, second); |
| 1213 | |
| 1214 | case '%': |
| 1215 | return MathLib::mod(first, second); |
| 1216 | |
| 1217 | case '&': |
| 1218 | return MathLib::toString(MathLib::toBigNumber(first) & MathLib::toBigNumber(second)) + intsuffix(first, second); |
| 1219 | |
| 1220 | case '|': |
| 1221 | return MathLib::toString(MathLib::toBigNumber(first) | MathLib::toBigNumber(second)) + intsuffix(first, second); |
| 1222 | |
| 1223 | case '^': |
| 1224 | return MathLib::toString(MathLib::toBigNumber(first) ^ MathLib::toBigNumber(second)) + intsuffix(first, second); |
| 1225 | |
| 1226 | default: |
| 1227 | throw InternalError(nullptr, std::string("Unexpected action '") + action + "' in MathLib::calculate()."); |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | std::string MathLib::sin(const std::string &tok) |
| 1232 | { |