strconv: fix documentation
Also: minor performance fix for large precision results.
benchmark old ns/op new ns/op delta
strconv_test.BenchmarkFormatFloatDecimal 2734 2734 +0.00%
strconv_test.BenchmarkFormatFloat 3141 3139 -0.06%
strconv_test.BenchmarkFormatFloatExp 8970 8989 +0.21%
strconv_test.BenchmarkFormatFloatBig 3228 3208 -0.62%
Fixes #2535.
R=rsc
CC=golang-dev
https://golang.org/cl/5435089
diff --git a/src/pkg/strconv/ftoa.go b/src/pkg/strconv/ftoa.go
index b2413ee..692e3e4 100644
--- a/src/pkg/strconv/ftoa.go
+++ b/src/pkg/strconv/ftoa.go
@@ -46,7 +46,7 @@
// because correct rounding and the number of digits
// needed to identify f depend on the precision of the representation.
func FormatFloat(f float64, fmt byte, prec, bitSize int) string {
- return string(genericFtoa(make([]byte, 0, 16), f, fmt, prec, bitSize))
+ return string(genericFtoa(make([]byte, 0, max(prec+4, 24)), f, fmt, prec, bitSize))
}
// AppendFloat appends the string form of the floating-point number f,