-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Possible to limit precision of number types? #284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
First, please use Note that, as described in issue #98, you will not have round-trip reproducibility if you have fewer than 17 digits of precision. Despite that caveat, we could add a setting to limit the precision. However, I don't have time right now, but if you submit a PR, we could pull it. |
I saw you just closed this issue I'm interested in. What's the resolution? I just had a quick look at the code of StreamWriterBuilder and I think it's not too difficult to do. Is your request for a PR still open? I'll sit down and have a try at it if you're still interested. |
Great! |
I think the reason of this problem is that: jsoncpp library use the double type to present the float-point number. |
That makes sense. Thanks. |
anyone help? |
see the PR #381 |
|
Uh oh!
There was an error while loading. Please reload this page.
I have a json-based config where I write some parameters, and when my application closes it uses the
Json::StyledWriter
to save the latest state of my rootJson::Value
object. I understand that round trip floating point precision isn't guaranteed to be exact, but is there a way to avoid numbers such as0.15
being saved as0.14999999999999999
? This makes the config file difficult to read.One solution I was wondering about is whether I could limit the precision of floating point numbers, I rarely in this case want more than 4 significant decimals and that would at least improve the use case.
The text was updated successfully, but these errors were encountered: