-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Question] Current place in code to change floating point resolution #1191
Comments
I think I found a workaround, if I switch from float to double and then do this based on https://stackoverflow.com/a/11209187 before calling dump()
|
|
I've removed the d suffix from the floating point literals in the code snippet since as you point out, it's meaningless. |
Unfortunately, while this workaround has been working for me, it's not working reliably for my colleague. Presumably due to some numbers not being representable exactly enough as a double. |
It turns out my colleague just made a typo. Yesterday I tried about 50,000 floating point numbers with my code and they all were formatted with the correct number of decimal places However these numbers are all in the range from -60 to 60 so I don't know for sure that my code works reliably for every number. |
It's possible that once numbers get large enough that there is considerably less floating precision left to represent the part after the decimal point, my code starts failing. This could be tested with a loop that covers the representation range of the double type. |
I'd like to reduce the number of floating point digits produced by dump().
Where in json.hpp do I do that?
This old issue #768 says to replace std::numeric_limits<number_float_t>::digits10 at line 6701 but digits10 is no longer at that line. I tried replacing this symbol in dump_float() but it didn't do the trick and when I tried replacing every occurrence of this symbol in json.hpp I got assertion failures.
Thanks!
The text was updated successfully, but these errors were encountered: