Commit e171b97e authored by Rob Pike's avatar Rob Pike

fmt: document some undocumented details

Better explanation of width for floating-point values.
Explain that scanning does not handle %#q etc.

Fixes #4202.
Fixes #4206.

R=golang-dev, adg, rsc, iant
CC=golang-dev
https://golang.org/cl/6620074
parent eae25d43
...@@ -56,9 +56,12 @@ ...@@ -56,9 +56,12 @@
character '*', causing their values to be obtained from the next character '*', causing their values to be obtained from the next
operand, which must be of type int. operand, which must be of type int.
For numeric values, width sets the width of the field and precision For numeric values, width sets the minimum width of the field and
sets the number of places after the decimal, if appropriate. For precision sets the number of places after the decimal, if appropriate,
example, the format %6.2f prints 123.45. except that for %g/%G it sets the total number of digits. For example,
given 123.45 the format %6.2f prints 123.45 while %.4g prints 123.5.
The default precision for %e and %f is 6; for %g it is the smallest
number of digits necessary to identify the value uniquely.
For strings, width is the minimum number of characters to output, For strings, width is the minimum number of characters to output,
padding with spaces if necessary, and precision is the maximum padding with spaces if necessary, and precision is the maximum
...@@ -152,6 +155,7 @@ ...@@ -152,6 +155,7 @@
%T is not implemented %T is not implemented
%e %E %f %F %g %G are all equivalent and scan any floating point or complex value %e %E %f %F %g %G are all equivalent and scan any floating point or complex value
%s and %v on strings scan a space-delimited token %s and %v on strings scan a space-delimited token
Flags # and + are not implemented.
The familiar base-setting prefixes 0 (octal) and 0x The familiar base-setting prefixes 0 (octal) and 0x
(hexadecimal) are accepted when scanning integers without a (hexadecimal) are accepted when scanning integers without a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment