]> Cypherpunks.ru repositories - gostls13.git/commitdiff
math/big: document rounding for Rat.FloatToString
authorRobert Griesemer <gri@golang.org>
Wed, 22 Jul 2015 19:33:21 +0000 (12:33 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 22 Jul 2015 19:47:19 +0000 (19:47 +0000)
Fixes #11523.

Change-Id: I172f6facd555a1c6db76f25d5097343c20dea59a
Reviewed-on: https://go-review.googlesource.com/12507
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/math/big/ratconv.go
src/math/big/ratconv_test.go

index 778077b96ecb56a863ff05793991ef80620e8afc..961ff649a50c816fb20a75164fc78f5c318516e4 100644 (file)
@@ -205,7 +205,8 @@ func (x *Rat) RatString() string {
 }
 
 // FloatString returns a string representation of x in decimal form with prec
-// digits of precision after the decimal point and the last digit rounded.
+// digits of precision after the decimal point. The last digit is rounded to
+// nearest, with halves rounded away from zero.
 func (x *Rat) FloatString(prec int) string {
        if x.IsInt() {
                s := x.a.String()
index 16b3a1941810e2dcb5dc6d555bb5253e9d51953c..da2fdab4cab2bdce606959c37f5856701e8fb8b0 100644 (file)
@@ -113,6 +113,8 @@ var floatStringTests = []struct {
        {"1", 0, "1"},
        {"1", 2, "1.00"},
        {"-1", 0, "-1"},
+       {"0.05", 1, "0.1"},
+       {"-0.05", 1, "-0.1"},
        {".25", 2, "0.25"},
        {".25", 1, "0.3"},
        {".25", 3, "0.250"},