Commit ded94115 authored by Eric Ponce's avatar Eric Ponce Committed by Ian Lance Taylor

math: add Round and RoundToEven examples

Change-Id: Ibef5f96ea588d17eac1c96ee3992e01943ba0fef
Reviewed-on: https://go-review.googlesource.com/131496
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 61318d7f
......@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment