-
Type: Bug
-
Resolution: Works as Designed
-
Priority: 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.
- is related to
-
CDRIVER-652 Number formatting and whitespace in bson_as_json
- Closed
- related to
-
CDRIVER-3626 Creating bson from json: Losing decimal digits in QT application
- Closed
-
CDRIVER-3938 Rounding errors in double type in bson_as_relaxed_extended_json() function
- Closed
-
CDRIVER-4819 Allow reducing precision when converting BSON double values to JSON
- Backlog