diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index 8fea77ba9..033ecfaa0 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -299,7 +299,9 @@ std::string MathLib::abs(const std::string &tok) bool MathLib::isEqual(const std::string &first, const std::string &second) { - return toDoubleNumber(first) == toDoubleNumber(second); + // this conversion is needed for formating + // e.g. if first=0.1 and second=1.0E-1, the direct comparison of the strings whould fail + return toString(toDoubleNumber(first)) == toString(toDoubleNumber(second)); } bool MathLib::isNotEqual(const std::string &first, const std::string &second) diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index 65e7d2d96..f68b1c98c 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -44,7 +44,6 @@ private: TEST_CASE(isLessEqual) } - void isGreater() { ASSERT_EQUALS(true , MathLib::isGreater("1.0", "0.001")); @@ -63,6 +62,7 @@ private: { ASSERT_EQUALS(true , MathLib::isEqual("1.0", "1.0")); ASSERT_EQUALS(false , MathLib::isEqual("1.", "1.01")); + ASSERT_EQUALS(true , MathLib::isEqual("0.1","1.0E-1")); } void isNotEqual()