diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index c540c73e8..0f778ee3a 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -131,6 +131,10 @@ bool MathLib::isFloat(const std::string &s) case LEADING_DECIMAL: if (std::isdigit(*it)) state=BASE_DIGITS2; + else if (*it=='e' || *it=='E') + state=E; + else + return false; break; case BASE_DIGITS1: if (*it=='e' || *it=='E') diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index ea4983155..f1b60db6e 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -368,6 +368,9 @@ private: ASSERT_EQUALS(false , MathLib::isFloat(" 0. ")); ASSERT_EQUALS(false , MathLib::isFloat(" 0.")); + ASSERT_EQUALS(false , MathLib::isFloat("0..")); + ASSERT_EQUALS(false , MathLib::isFloat("..0..")); + ASSERT_EQUALS(false , MathLib::isFloat("..0")); ASSERT_EQUALS(true , MathLib::isFloat("0.0")); ASSERT_EQUALS(true , MathLib::isFloat("-0.")); ASSERT_EQUALS(true , MathLib::isFloat("+0."));