Fixed #5142 (False positive with floating-point special cases in conditions)
This commit is contained in:
parent
a50e5c2c23
commit
769b4617c3
|
@ -287,7 +287,7 @@ std::string MathLib::divide(const std::string &first, const std::string &second)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(0, "Internal Error: Division by zero");
|
||||||
return toString(toLongNumber(first) / b);
|
return toString(toLongNumber(first) / b);
|
||||||
} else if (second == "0.0") {
|
} else if (second == "0.0") {
|
||||||
return "inf.0";
|
return (first[0] == '-') ? "-inf.0" : "inf.0";
|
||||||
}
|
}
|
||||||
return toString(toDoubleNumber(first) / toDoubleNumber(second));
|
return toString(toDoubleNumber(first) / toDoubleNumber(second));
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,7 +377,7 @@ private:
|
||||||
void naninf() {
|
void naninf() {
|
||||||
ASSERT_EQUALS("inf.0", MathLib::divide("0.0", "0.0")); // nan
|
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
|
ASSERT_EQUALS("-inf.0", MathLib::divide("-3.0", "0.0")); // -inf (#5142)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue