| Index: Source/platform/Decimal.cpp
|
| diff --git a/Source/platform/Decimal.cpp b/Source/platform/Decimal.cpp
|
| index 35b5a8aaf4e6ccb7b197748fb647de2968e950fc..97013153dc5eabf11bde42d383cb1bb0b03d6eda 100644
|
| --- a/Source/platform/Decimal.cpp
|
| +++ b/Source/platform/Decimal.cpp
|
| @@ -488,13 +488,18 @@ Decimal Decimal::operator/(const Decimal& rhs) const
|
| uint64_t remainder = lhs.m_data.coefficient();
|
| const uint64_t divisor = rhs.m_data.coefficient();
|
| uint64_t result = 0;
|
| - while (result < MaxCoefficient / 100) {
|
| - while (remainder < divisor) {
|
| + for (;;) {
|
| + while (remainder < divisor && result < MaxCoefficient / 10) {
|
| remainder *= 10;
|
| result *= 10;
|
| --resultExponent;
|
| }
|
| - result += remainder / divisor;
|
| + if (remainder < divisor)
|
| + break;
|
| + uint64_t quotient = remainder / divisor;
|
| + if (result > MaxCoefficient - quotient)
|
| + break;
|
| + result += quotient;
|
| remainder %= divisor;
|
| if (!remainder)
|
| break;
|
| @@ -628,7 +633,7 @@ Decimal Decimal::ceil() const
|
| uint64_t result = m_data.coefficient();
|
| const int numberOfDigits = countDigits(result);
|
| const int numberOfDropDigits = -exponent();
|
| - if (numberOfDigits < numberOfDropDigits)
|
| + if (numberOfDigits <= numberOfDropDigits)
|
| return isPositive() ? Decimal(1) : zero(Positive);
|
|
|
| result = scaleDown(result, numberOfDropDigits);
|
|
|