Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4905

EJSON looses precision on double values in canonical format

    • 2
    • Not Needed
    • Not Needed

      What problem are you facing?

      When using EJSON stringify (relaxed=false) double's are forced to be no longer than 13 digits. The change was introduced in v4.1.0 (NODE-2431, DRIVERS-792, SPEC-1537) to support compatibility with other drivers. The spec change was intended to make the tests more portable and not to make changes to library functionality. We should support the maximum precision that javascript can support.

      What driver and relevant dependency versions are you using?

      BSON v4.1.0 or later

      Steps to reproduce?

      EJSON.stringify({a: new Double(1639852160931802)}, { relaxed: false })
      // {"a":{"$numberDouble":"1.6398521609318E+15"}}
      

      Note, the output value is forced to exponential notation that ends in "318" which will cut off the "02" from the original number when restored to a javascript value.

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: