aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorkakulisen <lziqiang1@gmail.com>2020-04-30 14:18:06 +0800
committerRobert Griesemer <gri@golang.org>2020-05-02 20:22:19 +0000
commite90b0ce68b12a75732f28b6672d4c48ca73eaffe (patch)
tree31db1488a15fe569a6989d828c9d364256d9e69c /src/math
parent2d323f900df420a29de29cbab949eea08e3d1a61 (diff)
downloadgo-e90b0ce68b12a75732f28b6672d4c48ca73eaffe.tar.gz
go-e90b0ce68b12a75732f28b6672d4c48ca73eaffe.zip
math: add function examples.
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>
Diffstat (limited to 'src/math')
-rw-r--r--src/math/example_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/math/example_test.go b/src/math/example_test.go
index ce9c383256..9fc1967967 100644
--- a/src/math/example_test.go
+++ b/src/math/example_test.go
@@ -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
+}