[CDRIVER-2612] bson_as_json prints insignificant digits for doubles Created: 13/Apr/18 Updated: 26/Apr/18 Resolved: 26/Apr/18 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | None |
| Fix Version/s: | 1.10.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Jeroen Ooms [X] | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Unfortunately a new number formatting similar to issue: https://jira.mongodb.org/browse/CDRIVER-652. The bson_as_json function prints many insignificant digits for doubles:
OTOH, the mongo command line utility prints the correct number of digits for the same data:
|
| Comments |
| Comment by A. Jesse Jiryu Davis [ 13/Apr/18 ] |
|
Go for it! |
| Comment by Jeroen Ooms [X] [ 13/Apr/18 ] |
|
OK. Do you mind if I fix it in my copy of the vendored libmongoc code? The incorrect digits at the end are a bit unfortunate for us. |
| Comment by A. Jesse Jiryu Davis [ 13/Apr/18 ] |
|
Sorry, Jeroen, I'm not going to change this again. |
| Comment by Jeroen Ooms [X] [ 13/Apr/18 ] |
|
It's not a blocker but it's not optimal. The example above shows that you are printing noise at the end, which is incorrect and makes the json payload larger than needed. Perhaps we can make the "%.20g" format a macro so that I can set it back to %.15g for my client? The command line util seems to do the correct thing though. |
| Comment by A. Jesse Jiryu Davis [ 13/Apr/18 ] |
|
Thanks Jeroen. The C Driver formats doubles with "%.20g", which was updated from "%.15g" some time after |