Fixed #5142 (False positive with floating-point special cases in conditions)

This commit is contained in:
Daniel Marjamäki 2013-11-02 22:58:23 +01:00
parent a50e5c2c23
commit 769b4617c3
2 changed files with 2 additions and 2 deletions

View File

@ -287,7 +287,7 @@ std::string MathLib::divide(const std::string &first, const std::string &second)
throw InternalError(0, "Internal Error: Division by zero");
return toString(toLongNumber(first) / b);
} else if (second == "0.0") {
return "inf.0";
return (first[0] == '-') ? "-inf.0" : "inf.0";
}
return toString(toDoubleNumber(first) / toDoubleNumber(second));
}

View File

@ -377,7 +377,7 @@ private:
void naninf() {
ASSERT_EQUALS("inf.0", MathLib::divide("0.0", "0.0")); // nan
ASSERT_EQUALS("inf.0", MathLib::divide("3.0", "0.0")); // inf
ASSERT_EQUALS("inf.0", MathLib::divide("-3.0", "0.0")); // -inf
ASSERT_EQUALS("-inf.0", MathLib::divide("-3.0", "0.0")); // -inf (#5142)
}
};