fmt: the "alternate form" (the # flag) for floating point is not supported #18857
Labels
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/gyq-AzXEXg
What did you expect to see?
This is what the analogous C or C++ program produces.
In C or C++, the
#
flag for the floating-point (a
,A
,e
,E
,f
,F
,g
, andG
) conversions specifies thatIn addition, for the
g
andG
conversions, it specifies thatSince the formatting of Go's
fmt
package is analogous to C'sstdio
functions, it's naturally expected that the former would respect this aspect as well. In particular, in a scientific context, it's crucially important to have"%#.4g"
produce the same number of significant digits, either for 123.0 or 123.4; formatting 123.0 as "123" or "123." would imply only 3 significant digits, instead of 4.What did you see instead?
The
#
flag doesn't have any effect, and the decimal-point characters and the trailing zeros are removed the formatting result.The text was updated successfully, but these errors were encountered: