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

non-obvious formatting of floating point numbers #3657

Closed
Roman-Koshelev opened this issue Sep 27, 2023 · 3 comments
Closed

non-obvious formatting of floating point numbers #3657

Roman-Koshelev opened this issue Sep 27, 2023 · 3 comments
Labels

Comments

@Roman-Koshelev
Copy link
Contributor

  1. If the value representation type is not specified, then it is not g. A mandatory zero is added after the period. The number does not match the shortest representation.
  2. Fixed point has a fixed precision of 6 digits. Only significant digits are expected (it doesn't matter if there are more than 6 or less)
    https://godbolt.org/z/EEEedePaf

Somewhere it was written about compatibility with std. Will this be fixed?

@vitaut
Copy link
Contributor

vitaut commented Sep 27, 2023

std::to_chars is a completely different API and we don't provide any compatibility guarantees with it.

@Roman-Koshelev
Copy link
Contributor Author

Roman-Koshelev commented Sep 29, 2023

But std::format is built on top of it and is compatible. fmt::format won't be fully compatible with std ?
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html

@vitaut
Copy link
Contributor

vitaut commented Sep 30, 2023

std::format is specified in terms of std::to_chars but for your examples to make sense you need to correctly form invocations to the latter. It doesn't make a lot of sense to talk about abstract compatibility of the two APIs. fmt::format is compatible with std::format on numeric types with one exception related to precision already tracked in #3649.

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

No branches or pull requests

2 participants