Decimal constructor with 99999999999999999 loses last digit
https://bugs.webkit.org/show_bug.cgi?id=91579
Reviewed by Kent Tamura.
Source/WebCore:
This patch changes maximum coefficient value handling in Decimal::EncodedData
constructor not to lose the last digit. It was used ">=" operator for
comparison instead of ">" operator.
Tests: WebKit/chromium/tests/DecimalTest.cpp
* platform/Decimal.cpp:
(WebCore::Decimal::EncodedData::EncodedData): Replace ">=" to ">" for
not getting rid of the last digit for maximum coefficient value.
Source/WebKit/chromium:
This patch adds test cases for Decimal::EncodedData constructors for
testing edge cases in addition to common cases which they aren't
covered by other test cases.
* tests/DecimalTest.cpp:
(EXPECT_DECIMAL_ENCODED_DATA_EQ): Introduce a new macro for ease of
writing test cases for verifying components of Decimal::EncodedData.
(TEST_F): Added a new test entry DecimalTest.Constructor.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@122922 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/Decimal.cpp b/Source/WebCore/platform/Decimal.cpp
index 3bb6570..1472dc1 100644
--- a/Source/WebCore/platform/Decimal.cpp
+++ b/Source/WebCore/platform/Decimal.cpp
@@ -246,7 +246,7 @@
, m_sign(sign)
{
if (exponent >= ExponentMin && exponent <= ExponentMax) {
- while (coefficient >= MaxCoefficient) {
+ while (coefficient > MaxCoefficient) {
coefficient /= 10;
++exponent;
}