]> Cypherpunks repositories - gostls13.git/commitdiff
math: Add a function example
authorkakulisen <lziqiang1@gmail.com>
Wed, 29 Apr 2020 07:43:11 +0000 (15:43 +0800)
committerRobert Griesemer <gri@golang.org>
Thu, 30 Apr 2020 00:33:38 +0000 (00:33 +0000)
When I browsed the source code, I saw that there is no corresponding example of this function. I am not sure if there is a need for an increase, this is my first time to submit CL.

Change-Id: Idbf4e1e1ed2995176a76959d561e152263a2fd26
Reviewed-on: https://go-review.googlesource.com/c/go/+/230741
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/math/example_test.go

index 50c74269792c7a8d602942716aeae66adc7e954a..ce9c38325659fb96fec551042332a0bbce6887b3 100644 (file)
@@ -219,3 +219,11 @@ func ExampleTrunc() {
        // 3.00
        // -1.00
 }
+
+func ExampleCbrt() {
+       fmt.Printf("%.2f\n", math.Cbrt(8))
+       fmt.Printf("%.2f\n", math.Cbrt(27))
+       // Output:
+       // 2.00
+       // 3.00
+}