]> Cypherpunks repositories - gostls13.git/commitdiff
math: add examples to Ceil, Floor, Pow, Pow10 functions
authorAndrii Soldatenko <andrii.soldatenko@gmail.com>
Wed, 13 Jun 2018 15:58:09 +0000 (18:58 +0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 13 Jun 2018 22:01:28 +0000 (22:01 +0000)
Change-Id: I9154df128b349c102854bb0f21e4c313685dd0e6
Reviewed-on: https://go-review.googlesource.com/118659
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/math/example_test.go

index feaf9d825255521d0d6e405bee584509747c32cc..a1f764bcdaabcba7b9aed385bbe4c4f9947b242b 100644 (file)
@@ -89,3 +89,27 @@ func ExampleSqrt() {
        fmt.Printf("%.1f", c)
        // Output: 5.0
 }
+
+func ExampleCeil() {
+       c := math.Ceil(1.49)
+       fmt.Printf("%.1f", c)
+       // Output: 2.0
+}
+
+func ExampleFloor() {
+       c := math.Floor(1.51)
+       fmt.Printf("%.1f", c)
+       // Output: 1.0
+}
+
+func ExamplePow() {
+       c := math.Pow(2, 3)
+       fmt.Printf("%.1f", c)
+       // Output: 8.0
+}
+
+func ExamplePow10() {
+       c := math.Pow10(2)
+       fmt.Printf("%.1f", c)
+       // Output: 100.0
+}