aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartynas Budriƫnas <mabu@google.com>2017-07-15 12:58:19 -0600
committerBrad Fitzpatrick <bradfitz@golang.org>2017-07-15 20:12:22 +0000
commit41af3fa33ed54c1cb2095385f723ba1636485a11 (patch)
treea8e3d46df52019378d2f3fd9697f15c665658b52
parent8cb40fa4215c736aed011fe8b580ade7150acffa (diff)
downloadgo-41af3fa33ed54c1cb2095385f723ba1636485a11.tar.gz
go-41af3fa33ed54c1cb2095385f723ba1636485a11.zip
math: add a Sqrt example
Change-Id: I259e25b9d0b069912053a250e9739e04fafca54d Reviewed-on: https://go-review.googlesource.com/48892 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/math/example_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/math/example_test.go b/src/math/example_test.go
new file mode 100644
index 0000000000..12e9876730
--- /dev/null
+++ b/src/math/example_test.go
@@ -0,0 +1,20 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package math_test
+
+import (
+ "fmt"
+ "math"
+)
+
+func ExampleSqrt() {
+ const (
+ a = 3
+ b = 4
+ )
+ c := math.Sqrt(a*a + b*b)
+ fmt.Printf("%.1f", c)
+ // Output: 5.0
+}