-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Floating-point formatting defaults differ from iostream/Boost.Format #1893
Comments
This is not what I was saying. I was explaining what is the main difference between the default format and At this point the format is fixed for compatibility with |
In lack of having access to the C++20 standard, I read https://en.cppreference.com/w/cpp/utility/format/formatter which currently state the following available floating-point presentation types;
That lead me to test what |
What do the specs say about |
|
Did the docs get updated? They state that the default presentation type for floating point values is:
I might just be misunderstanding that, but it seems to describe the old behaviour. |
They are updated now (https://fmt.dev/dev/syntax.html), thanks. |
The default is "g" in std::iostreams and boost::format. This is also the default in .NET-based languages (C#, F#, VB.NET), Rust, R.
The default is "g with at least one digit past the decimal point" in fmt. This is also the default in Python.
This can lead to hard to find bugs when porting from one of these libraries to fmt.
The rationale for the default in fmt is that;
May I ask how is
"1.0"
more round-trippable than"1"
, given a floating-point context for the value of 1?The documentation does not mention round-trip guarantees for the
{}
format specifier, perhaps it should?May I suggest another format specifier for round-tripping, what about
{:R}
?But as per usual, there are almost uncountable different ways software engineers prefer their floating-points to be formatted by default. 😂
The text was updated successfully, but these errors were encountered: