diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index 2d5555b34..6b07df126 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -116,7 +116,7 @@ bool MathLib::isHex(const std::string& str) bool MathLib::isBin(const std::string& str) { bool sign = str[0]=='-' || str[0]=='+'; - return(str.compare(sign?1:0, 2, "0b") == 0 && str.find_first_not_of("10b", 1) == std::string::npos); + return((str.compare(sign?1:0, 2, "0b") == 0 || str.compare(sign?1:0, 2, "0B") == 0) && str.find_first_not_of("10bB", 1) == std::string::npos); } bool MathLib::isInt(const std::string & s) diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index 3a8ba9022..5a91aff38 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -171,6 +171,7 @@ private: ASSERT_EQUALS(-1 , MathLib::toLongNumber("-0b1")); ASSERT_EQUALS(215 , MathLib::toLongNumber("0b11010111")); ASSERT_EQUALS(-215 , MathLib::toLongNumber("-0b11010111")); + ASSERT_EQUALS(215 , MathLib::toLongNumber("0B11010111")); // from base 10 ASSERT_EQUALS(10 , MathLib::toLongNumber("10"));