Skip to content
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

Consistent conversions between double and string #1359

Open
eggrobin opened this issue May 6, 2017 · 0 comments
Open

Consistent conversions between double and string #1359

eggrobin opened this issue May 6, 2017 · 0 comments

Comments

@eggrobin
Copy link
Member

eggrobin commented May 6, 2017

At the moment logging logs double in a lossy way, and we variably use snprintf, MSVC's sprintf_s, << and std::setprecision(std::numeric_limits<long double>::digits10 + 1), or std::setprecision(std::numeric_limits<long double>::max_digits10) when we need reversible lossless conversion to string.
This should be unified, our logs should be lossless as much as possible, and we should be compatible with the way proto does things (which is locale-independent). A simple solution would be to just call the relevant protobuf function (NoLocaleStrtod) for parsing.
For printing we may have different needs, since SimpleDtoa tries to do very smart things, and we care about numbers having a constant width in our logs, which is why we explicitly log the +.
We could overload operator<< for LogStream so that logging uses our unified DebugString. Similarly, we could do that on our OFStream (we should also eliminate direct use of std::ofstream from our codebase).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant