]> Cypherpunks repositories - gostls13.git/commitdiff
math: add function examples.
authorkakulisen <lziqiang1@gmail.com>
Thu, 30 Apr 2020 06:18:06 +0000 (14:18 +0800)
committerRobert Griesemer <gri@golang.org>
Sat, 2 May 2020 20:22:19 +0000 (20:22 +0000)
The function Modf lacks corresponding examples.

Change-Id: Id93423500e87d35b0b6870882be1698b304797ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/231097
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/math/example_test.go

index ce9c38325659fb96fec551042332a0bbce6887b3..9fc196796796c9ac1c1406a53242741fc207284d 100644 (file)
@@ -227,3 +227,14 @@ func ExampleCbrt() {
        // 2.00
        // 3.00
 }
+
+func ExampleModf() {
+       int, frac := math.Modf(3.14)
+       fmt.Printf("%.2f, %.2f\n", int, frac)
+
+       int, frac = math.Modf(-2.71)
+       fmt.Printf("%.2f, %.2f\n", int, frac)
+       // Output:
+       // 3.00, 0.14
+       // -2.00, -0.71
+}