This commit is contained in:
parent
4172011e78
commit
b6858622eb
|
@ -617,10 +617,10 @@ std::string MathLib::divide(const std::string &first, const std::string &second)
|
|||
if (MathLib::isInt(first) && MathLib::isInt(second)) {
|
||||
const bigint a = toLongNumber(first);
|
||||
const bigint b = toLongNumber(second);
|
||||
if (a == std::numeric_limits<bigint>::min())
|
||||
throw InternalError(0, "Internal Error: Division overflow");
|
||||
if (b == 0)
|
||||
throw InternalError(0, "Internal Error: Division by zero");
|
||||
if (a == std::numeric_limits<bigint>::min() && std::abs(b)<=1)
|
||||
throw InternalError(0, "Internal Error: Division overflow");
|
||||
return toString(toLongNumber(first) / b) + intsuffix(first, second);
|
||||
} else if (isNullValue(second)) {
|
||||
if (isNullValue(first))
|
||||
|
|
|
@ -139,6 +139,7 @@ private:
|
|||
ASSERT_EQUALS("1" , MathLib::divide("3", "2"));
|
||||
ASSERT_THROW(MathLib::divide("123", "0"), InternalError); // throw
|
||||
ASSERT_THROW(MathLib::divide("-9223372036854775808", "-1"), InternalError); // #4520 - out of range => throw
|
||||
ASSERT_EQUALS("4611686018427387904", MathLib::divide("-9223372036854775808", "-2")); // #6679
|
||||
MathLib::divide("123", "0.0"); // don't throw
|
||||
|
||||
// Unknown action should throw exception
|
||||
|
|
Loading…
Reference in New Issue