From: kakulisen Date: Thu, 30 Apr 2020 06:18:06 +0000 (+0800) Subject: math: add function examples. X-Git-Tag: go1.15beta1~243 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e90b0ce68b12a75732f28b6672d4c48ca73eaffe;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- 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 +}