]> Cypherpunks repositories - gostls13.git/commitdiff
strconv: fix documentation
authorRobert Griesemer <gri@golang.org>
Wed, 7 Dec 2011 22:45:45 +0000 (14:45 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 7 Dec 2011 22:45:45 +0000 (14:45 -0800)
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

src/pkg/strconv/atoi.go
src/pkg/strconv/ftoa.go

index 438d496948d4522958f27a260fef6f7d4be7e0cc..b0e584e193f90ae90f1fd509d7620795755c8fda 100644 (file)
@@ -119,10 +119,10 @@ Error:
        return n, &NumError{s0, err}
 }
 
-// ParseInt interprets a string s in an arbitrary base b (2 to 36)
-// and returns the corresponding value n.  If b == 0, the base
-// is taken from the string prefix: base 16 for "0x", base 8 for "0",
-// and base 10 otherwise.
+// ParseInt interprets a string s in the given base (2 to 36) and
+// returns the corresponding value i.  If base == 0, the base is
+// implied by the string's prefix: base 16 for "0x", base 8 for
+// "0", and base 10 otherwise.
 //
 // The bitSize argument specifies the integer type
 // that the result must fit into.  Bit sizes 0, 8, 16, 32, and 64
index b2413eee6b4573c6580d6e3621f9ed2d216422c3..692e3e4087520ff28c8ac79b796b515a4abef4b0 100644 (file)
@@ -46,7 +46,7 @@ var float64info = floatInfo{52, 11, -1023}
 // 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,