Summary: | Decimal::toString should not round integer value. | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | yosin | ||||||||
Component: | Platform | Assignee: | yosin | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | tkent | ||||||||
Priority: | P2 | ||||||||||
Version: | 528+ (Nightly build) | ||||||||||
Hardware: | Unspecified | ||||||||||
OS: | Unspecified | ||||||||||
Bug Depends on: | 91572, 91579 | ||||||||||
Bug Blocks: | |||||||||||
Attachments: |
|
Description
yosin
2012-07-17 03:00:32 PDT
Created attachment 152724 [details]
Patch 1
Comment on attachment 152724 [details]
Patch 1
Could you review this patch?
Thanks in advance.
P.S.
Changes for Decimal.cpp is only adding "if (originalExponent < 0)" and indentation. git diff -w Decimal.cpp shows two line changes.
Comment on attachment 152724 [details] Patch 1 View in context: https://bugs.webkit.org/attachment.cgi?id=152724&action=review > Source/WebCore/ChangeLog:14 > + (WebCore::Decimal::toString): When the value is an integer, we don't > + round coefficient to DBL_DIG(15) digits. Why do we need the rounding for non-integer cases? > Source/WebKit/chromium/tests/DecimalTest.cpp:1045 > + // 8639999913600001=Date.UTC(275760, 8, 12, 0, 0, 0 1) Understing it helps nothing. Please remove the comment. > Source/WebKit/chromium/tests/DecimalTest.cpp:1046 > + EXPECT_STREQ(("8639999913600001"), encode(8639999913600001, 0, Positive).toString().ascii().data()); We need more test cases. For example, MaxCoefficient with various exponents. Created attachment 152904 [details]
Patch 2
Created attachment 152949 [details]
Patch 3
(In reply to comment #3) > (From update of attachment 152724 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=152724&action=review > > > Source/WebCore/ChangeLog:14 > > + (WebCore::Decimal::toString): When the value is an integer, we don't > > + round coefficient to DBL_DIG(15) digits. > > Why do we need the rounding for non-integer cases? The reason is we would like to get "1" for 1/3 * 3 or 1/256 * 256. Using DBL_DIG is chosen by converting Decimal to double, e.g. HTMLInputElement.valueAsNumber method. Comment on attachment 152949 [details]
Patch 3
Could you review this patch?
Thanks in advance.
= Changes since the last review =
* Added more tests as suggested.
* Use newly introduced macro EXPECT_DECIMAL_STREQ.
Comment on attachment 152949 [details]
Patch 3
ok
Comment on attachment 152949 [details] Patch 3 Clearing flags on attachment: 152949 Committed r122928: <http://trac.webkit.org/changeset/122928> All reviewed patches have been landed. Closing bug. |