]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: add function example
authorzhouzhongyuan <zhouzhongyuan96@gmail.com>
Fri, 8 May 2020 10:13:58 +0000 (18:13 +0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 26 Aug 2020 16:15:32 +0000 (16:15 +0000)
While reading the source code of the math/big package, I found the SetString function example of float type missing.

Change-Id: Id8c16a58e2e24f9463e8ff38adbc98f8c418ab26
Reviewed-on: https://go-review.googlesource.com/c/go/+/232804
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/math/big/example_test.go

index cfc77351d4e3fc66fda7b571ed610aa50663810b..31ca784154c2cf660ca8062971ab35b6532a2985 100644 (file)
@@ -25,6 +25,13 @@ func ExampleInt_SetString() {
        // Output: 420
 }
 
+func ExampleFloat_SetString() {
+       f := new(big.Float)
+       f.SetString("3.14159")
+       fmt.Println(f)
+       // Output: 3.14159
+}
+
 func ExampleRat_Scan() {
        // The Scan function is rarely used directly;
        // the fmt package recognizes it as an implementation of fmt.Scanner.