-
Type: Task
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
C Drivers
In _bson_as_json_visit_double, BSON double values are converted to strings with a precision of 20 decimal digits. This can lead to issue for some values when they are rounded at the default double precision (~16 digits) but not at the extended precision. An example for such a value is 1.99, which translates to 1.9899999999999999911 when 20 digits precision are available.
This is problematic, as users using a value like above are presented with a different value in the resulting JSON. I'll note that reading the resulting JSON into BSON results in the original value, as the 20 digit precision is not available in a C double.
A possible solution is changing the precision to a lower value: the 53 bits of precision in a double result in 16 digits of decimal precision. If this can be considered a BC break, adding a precision option to _bson_json_opts_t for use in bson_as_json_with_opts could provide a workaround for affected users.
- is caused by
-
CDRIVER-1945 bson_as_json outputs doubles as integers
- Closed
- is depended on by
-
PHPC-2341 Approximative encoding of floats in canonical extended JSON
- Blocked
- is related to
-
CDRIVER-2063 JSON export prints insignificant digits / noise
- Closed
-
CDRIVER-3377 Double value retrieved from bson is different than expected
- Closed
-
CDRIVER-3938 Rounding errors in double type in bson_as_relaxed_extended_json() function
- Closed
-
CDRIVER-3500 Reduce floating point precision required of extended json implementations
- Backlog