From: Eric Ponce Date: Sun, 26 Aug 2018 17:32:07 +0000 (+0200) Subject: math: add Round and RoundToEven examples X-Git-Tag: go1.12beta1~1245 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ded941158042d8b09164a9f8049fd7108b715680;p=gostls13.git math: add Round and RoundToEven examples Change-Id: Ibef5f96ea588d17eac1c96ee3992e01943ba0fef Reviewed-on: https://go-review.googlesource.com/131496 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/math/example_test.go b/src/math/example_test.go index a1f764bcda..25d6975903 100644 --- a/src/math/example_test.go +++ b/src/math/example_test.go @@ -113,3 +113,25 @@ func ExamplePow10() { fmt.Printf("%.1f", c) // Output: 100.0 } + +func ExampleRound() { + p := math.Round(10.5) + fmt.Printf("%.1f\n", p) + + n := math.Round(-10.5) + fmt.Printf("%.1f\n", n) + // Output: + // 11.0 + // -11.0 +} + +func ExampleRoundToEven() { + u := math.RoundToEven(11.5) + fmt.Printf("%.1f\n", u) + + d := math.RoundToEven(12.5) + fmt.Printf("%.1f\n", d) + // Output: + // 12.0 + // 12.0 +}