-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Labels
state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
Description
When storing floating point values, exact representation is not possible.
ie: -0.2 -> -0.019999995827674866
However, when precision is not a big issue this introduces huge about of bloat in the JSON file. So there should be an option to specify how many characters of precision. Like it is possible in std::ostringstream (std::ostreams), and in printf.
Currently these 2 methods would be desired:
json j;
j["float"] = -0.123;
j.precision(2);
cout << j;
json j;
j["float"] = -0.123;
j.precision(2);
printf("%s", j.dump().c_str());
Desired: {"float":-0.12}
Currently: {"float":-0.12300000339746475}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated