Bug 91579 - Decimal constructor with 99999999999999999 loses last digit
Summary: Decimal constructor with 99999999999999999 loses last digit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: yosin
URL:
Keywords:
Depends on:
Blocks: 91481
  Show dependency treegraph
 
Reported: 2012-07-17 22:06 PDT by yosin
Modified: 2012-07-18 18:17 PDT (History)
2 users (show)

See Also:


Attachments
Patch 1 (5.53 KB, patch)
2012-07-17 22:22 PDT, yosin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description yosin 2012-07-17 22:06:23 PDT
There is a bug in Decimal::EncodedData constructor with maximum coefficient, 99999999999999999, in following line:


Decimal::EncodedData::EncodedData(Sign sign, int exponent, uint64_t coefficient)
{
  ...
    if (exponent >= ExponentMin && exponent <= ExponentMax) {
        while (coefficient >= MaxCoefficient) { // *** BUG, we should use ">" instead of ">=".
            coefficient /= 10;
            ++exponent;
        }
    }
  ...
}
Comment 1 yosin 2012-07-17 22:22:34 PDT
Created attachment 152918 [details]
Patch 1
Comment 2 yosin 2012-07-17 22:23:31 PDT
Comment on attachment 152918 [details]
Patch 1

Could you review this patch?
Thanks in advance.
Comment 3 Kent Tamura 2012-07-17 22:36:10 PDT
Comment on attachment 152918 [details]
Patch 1

looks ok
Comment 4 yosin 2012-07-17 23:50:34 PDT
Comment on attachment 152918 [details]
Patch 1

Clearing flags on attachment: 152918

Committed r122922: <http://trac.webkit.org/changeset/122922>
Comment 5 yosin 2012-07-17 23:50:39 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Alexey Proskuryakov 2012-07-18 10:41:43 PDT
This is fixing Platform code. Is that code used anywhere? An actual regression test would be vastly preferable to a unit test (which is not even cross-platform!)
Comment 7 yosin 2012-07-18 18:17:17 PDT
(In reply to comment #6)
> This is fixing Platform code. Is that code used anywhere? An actual regression test would be vastly preferable to a unit test (which is not even cross-platform!)

The code is used in step-able input types, number, date, range, datetime, and so on. Although, it is hard to hit this case from HTML5/JavaScript, because the value is out of range of double.

The purpose of fixing this is for test case (bug 91481) and that test case is supplement for LayoutTest.