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

fmt: missing bits of documentation #4206

Closed
gopherbot opened this issue Oct 7, 2012 · 2 comments
Closed

fmt: missing bits of documentation #4206

gopherbot opened this issue Oct 7, 2012 · 2 comments
Assignees
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 7, 2012

by chris.jones.yar:

http://play.golang.org/p/FT7yR1p4-_

What is the expected output?
I expect both lines of output to be identical.

What do you see instead?
The output from "%7g" is not limited to 7 characters, but from "%7f"
it is.

Which compiler are you using (5g, 6g, 8g, gccgo)?


Which operating system are you using?


Which version are you using?  (run 'go version')


Please provide any additional information below.
@rsc
Copy link
Contributor

@rsc rsc commented Oct 7, 2012

Comment 1:

The 7s in your example are doing nothing. Change them to 20s and
you'll see what they do. We should make the docs clearer.
godoc fmt:
    %e  scientific notation, e.g. -1234.456e+78
    %E  scientific notation, e.g. -1234.456E+78
    %f  decimal point but no exponent, e.g. 123.456
    %g  whichever of %e or %f produces more compact output
    %G  whichever of %E or %f produces more compact output
    ...
    For numeric values, width sets the width of the field and precision sets
    the number of places after the decimal, if appropriate. For example, the
    format %6.2f prints 123.45.
    For strings, width is the minimum number of characters to output,
    padding with spaces if necessary, and precision is the maximum number of
    characters to output, truncating if necessary.
Missing: (1) for numeric values, width sets the *minimum* width of the field.
(2) Default precision for e and f is 6; default precision for g is the smallest
number of digits needed to uniquely identify the value.

Owner changed to @robpike.

@robpike
Copy link
Contributor

@robpike robpike commented Oct 12, 2012

Comment 2:

This issue was closed by revision e171b97.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.