1. XStream
  2. XSTR-541

String values converted to numeric literals are losing precision in Javascript due to it's 64 bit floating point representation


    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.5
    • Component/s: None
    • Labels:


      The normal conversion of string values to JSON attempts to convert values to numeric values, but this is problematic for numeric values like 64 bit Long's when converted to Javascript, they are converted to 64 bit floating point values, so values larger than I believe 2^51 or something like that can lose precision.

      We can use the SimpleConverter and I put in an issue into XStream to ensure that users can configure the JettisonMappedXMLDriver, but even in the default behavior of Jettison we probably shouldn't allow numeric values that are larger than can be converted into 64 bit double precision floating point (although I guess that's a javascript specific limitation, and maybe Javascript can check that when it's evaluating and if the numeric value doesn't match what the string field was it would fail, but I'm not sure that's really easy to change).

      Here's the XStream patch with the issue, the solution right now is to simply use the SimpleConverter.


        • Assignee:
          Jörg Schaible
          Doug Daniels
        • Votes:
          0 Vote for this issue
          1 Start watching this issue


          • Created: