Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2063

JSON export prints insignificant digits / noise

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: json
    • None

      Since version 1.6 of the C driver, exporting data to JSON leads to unfortunate rounding/printing behavior. For example a simple value:

      > db.test.insert({"x":1.8})
      WriteResult({ "nInserted" : 1 })
      > db.test.find()
      { "_id" : ObjectId("58a84a0325b646783be8cf6e"), "x" : 1.8 }
      

      Previously, exporting this data with the C driver would lead to the correct output:

      > mongo("test")$export()
      { "_id" : { "$oid" : "58a84a0325b646783be8cf6e" }, "x" : 1.8 }
      

      However with the new C driver I get:

      > mongo("test")$export()
      { "_id" : { "$oid" : "58a84a0325b646783be8cf6e" }, "x" : 1.8000000000000000444 }
      

      Unfortunately this can be a serious problem for scientific applications where numeric precision is important.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jeroen.ooms Jeroen Ooms
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: