diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index bc5c76b1d..ec40a37ba 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -397,13 +397,8 @@ bool MathLib::isBin(const std::string& s) return state == DIGITS; } -bool MathLib::isInt(const std::string & s) +bool MathLib::isDec(const std::string & s) { - // check for two known types: hexadecimal and octal - if (isHex(s) || isOct(s)) { - return true; - } - enum {START, PLUSMINUS, DIGIT, SUFFIX} state = START; for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) { switch (state) { @@ -434,6 +429,11 @@ bool MathLib::isInt(const std::string & s) return state == DIGIT; } +bool MathLib::isInt(const std::string & s) +{ + return isDec(s) || isHex(s) || isOct(s); +} + std::string MathLib::add(const std::string & first, const std::string & second) { if (MathLib::isInt(first) && MathLib::isInt(second)) { diff --git a/lib/mathlib.h b/lib/mathlib.h index 246baa05f..4e66f748c 100644 --- a/lib/mathlib.h +++ b/lib/mathlib.h @@ -47,6 +47,7 @@ public: static bool isFloat(const std::string &str); static bool isNegative(const std::string &str); static bool isPositive(const std::string &str); + static bool isDec(const std::string & str); static bool isHex(const std::string& str); static bool isOct(const std::string& str); static bool isBin(const std::string& str);