Fixed #5142 (False positive with floating-point special cases in conditions)
This commit is contained in:
parent
dde46527f3
commit
8ff412fcee
|
@ -287,6 +287,10 @@ 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") {
|
||||
if (first=="0.0" || first=="+0.0")
|
||||
return "nan.0";
|
||||
if (first=="-0.0")
|
||||
return "-nan.0";
|
||||
return (first[0] == '-') ? "-inf.0" : "inf.0";
|
||||
}
|
||||
return toString(toDoubleNumber(first) / toDoubleNumber(second));
|
||||
|
|
|
@ -375,7 +375,7 @@ private:
|
|||
}
|
||||
|
||||
void naninf() {
|
||||
ASSERT_EQUALS("inf.0", MathLib::divide("0.0", "0.0")); // nan
|
||||
ASSERT_EQUALS("nan.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 (#5142)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue