Bug 44745 - Number.toFixed/toExponential/toPrecision are inaccurate.
Reviewed by Oliver Hunt.
These methods should be using a version of dtoa that can generate results accurate
to the requested precision, whereas our version of dtoa is only currently able to
support producing results sufficiently accurate to distinguish the value from any
other IEEE-754 double precision number.
JavaScriptCore:
This change has no impact on benchmarks we track.
On microbenchmarks for these functions, this is a slight regression where a high
precision is requested (dtoa now need to iterate further to generate a a greater
number of digits), but with smaller precision values (hopefully more common) this
improves performance, since it reduced the accurate of result dtoa is required,
to produce, and removes the need to pre-round values before calling dtoa.
doubleToStringInJavaScriptFormat renamed to numberToString
doubleToStringInJavaScriptFormat renamed to numberToString
(JSC::UString::number):
doubleToStringInJavaScriptFormat renamed to numberToString
(WTF::DecimalNumber::DecimalNumber):
(WTF::DecimalNumber::toStringDecimal):
(WTF::DecimalNumber::toStringExponential):
Remove all pre-rounding of values, instead call dtoa correctly.
(WTF::dtoa):
Reenable support for rounding to specific-figures/decimal-places in dtoa.
Modify to remove unbiased rounding, provide ECMA required away-from-zero.
Rewrite doubleToStringInJavaScriptFormat to use DecimalNumber, rename to
numberToString.
WebCore:
- html/HTMLTreeBuilder.cpp:
(WebCore::serializeForNumberType):
doubleToStringInJavaScriptFormat renamed to numberToString.
LayoutTests:
Updating expected results, corrected errors in fast/js/kde/script-tests/Number.js
(corrected results confirmed with FireFox).
- fast/js/kde/Number-expected.txt:
- fast/js/kde/script-tests/Number.js:
- fast/js/number-toExponential-expected.txt:
- fast/js/number-tofixed-expected.txt:
- fast/js/number-toprecision-expected.txt: