Ignore:
Timestamp:
Jul 3, 2011, 3:27:12 PM (14 years ago)
Author:
[email protected]
Message:

Reviewed by Sam Weinig.

https://bugs.webkit.org/show_bug.cgi?id=16652
Firefox and JavaScriptCore differ in Number.toString(integer)

Source/JavaScriptCore:

Our arbitrary radix (2..36) toString conversion is inaccurate.
This is partly because it uses doubles to perform math that requires
higher accuracy, and partly becasue it does not attempt to correctly
detect where to terminate, instead relying on a simple 'epsilon'.

  • runtime/NumberPrototype.cpp:

(JSC::decomposeDouble):

  • helper function to extract sign, exponent, mantissa from IEEE doubles.

(JSC::Uint16WithFraction::Uint16WithFraction):

  • helper class, u16int with infinite precision fraction, used to convert the fractional part of the number to a string.

(JSC::Uint16WithFraction::operator*=):

  • Multiply by a uint16.

(JSC::Uint16WithFraction::operator<):

  • Compare two Uint16WithFractions.

(JSC::Uint16WithFraction::floorAndSubtract):

  • Extract the integer portion of the number, and subtract it (clears the integer portion).

(JSC::Uint16WithFraction::comparePoint5):

  • Compare to 0.5.

(JSC::Uint16WithFraction::sumGreaterThanOne):

  • Passed a second Uint16WithFraction, returns true if the result of adding the two values would be greater than one.

(JSC::Uint16WithFraction::isNormalized):

  • Used by ASSERTs to consistency check internal representation.

(JSC::BigInteger::BigInteger):

  • helper class, unbounded integer value, used to convert the integer part of the number to a string.

(JSC::BigInteger::divide):

  • Divide this value through by a uint32.

(JSC::BigInteger::operator!):

  • test for zero.

(JSC::toStringWithRadix):

  • Performs number to string conversion, with the given radix (2..36).

(JSC::numberProtoFuncToString):

  • Changed to use toStringWithRadix.

Tools:

Added forwarding header.

  • DumpRenderTree/ForwardingHeaders/wtf/StdLibExtras.h: Added.

LayoutTests:

Our arbitrary radix (2..36) toString conversion is inaccurate.
This is partly because it uses doubles to perform math that requires
higher accuracy, and partly becasue it does not attempt to correctly
detect where to terminate, instead relying on a simple 'epsilon'.

  • fast/js/number-toString-expected.txt:
    • Update expected results from FAIL to PASS.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r90324 r90347  
     12011-06-30  Gavin Barraclough  <[email protected]>
     2
     3        Reviewed by Sam Weinig.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=16652
     6        Firefox and JavaScriptCore differ in Number.toString(integer)
     7
     8        Our arbitrary radix (2..36) toString conversion is inaccurate.
     9        This is partly because it uses doubles to perform math that requires
     10        higher accuracy, and partly becasue it does not attempt to correctly
     11        detect where to terminate, instead relying on a simple 'epsilon'.
     12
     13        * runtime/NumberPrototype.cpp:
     14        (JSC::decomposeDouble):
     15            - helper function to extract sign, exponent, mantissa from IEEE doubles.
     16        (JSC::Uint16WithFraction::Uint16WithFraction):
     17            - helper class, u16int with infinite precision fraction, used to convert
     18              the fractional part of the number to a string.
     19        (JSC::Uint16WithFraction::operator*=):
     20            - Multiply by a uint16.
     21        (JSC::Uint16WithFraction::operator<):
     22            - Compare two Uint16WithFractions.
     23        (JSC::Uint16WithFraction::floorAndSubtract):
     24            - Extract the integer portion of the number, and subtract it (clears the integer portion).
     25        (JSC::Uint16WithFraction::comparePoint5):
     26            - Compare to 0.5.
     27        (JSC::Uint16WithFraction::sumGreaterThanOne):
     28            - Passed a second Uint16WithFraction, returns true if the result of adding
     29              the two values would be greater than one.
     30        (JSC::Uint16WithFraction::isNormalized):
     31            - Used by ASSERTs to consistency check internal representation.
     32        (JSC::BigInteger::BigInteger):
     33            - helper class, unbounded integer value, used to convert the integer part
     34              of the number to a string.
     35        (JSC::BigInteger::divide):
     36            - Divide this value through by a uint32.
     37        (JSC::BigInteger::operator!):
     38            - test for zero.
     39        (JSC::toStringWithRadix):
     40            - Performs number to string conversion, with the given radix (2..36).
     41        (JSC::numberProtoFuncToString):
     42            - Changed to use toStringWithRadix.
     43
    1442011-07-02  Gavin Barraclough  <[email protected]>
    245
Note: See TracChangeset for help on using the changeset viewer.