aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-01-11 11:25:37 -0800
committerRuss Cox <rsc@golang.org>2010-01-11 11:25:37 -0800
commit093146b920123e32d503680d7a688f63a03fc40e (patch)
treec4ca21ef26a6072b5c01ae80ccc09b55dd095c9b
parent0ed728c48a0cfe7ad5dd90dbc0b9cc2558aa9424 (diff)
downloadgo-093146b920123e32d503680d7a688f63a03fc40e.tar.gz
go-093146b920123e32d503680d7a688f63a03fc40e.zip
math: fix pow10 comment, test portable Sqrt
R=r CC= golang-dev, Charlie Dorian, golang-dev https://golang.org/cl/184058
-rw-r--r--src/pkg/math/all_test.go11
-rw-r--r--src/pkg/math/pow10.go2
-rw-r--r--src/pkg/math/sqrt_test.go9
3 files changed, 17 insertions, 5 deletions
diff --git a/src/pkg/math/all_test.go b/src/pkg/math/all_test.go
index 04c273322b..7dcc41f41b 100644
--- a/src/pkg/math/all_test.go
+++ b/src/pkg/math/all_test.go
@@ -307,7 +307,6 @@ func alike(a, b float64) bool {
func TestAcos(t *testing.T) {
for i := 0; i < len(vf); i++ {
- // if f := Acos(vf[i] / 10); !veryclose(acos[i], f) {
if f := Acos(vf[i] / 10); !close(acos[i], f) {
t.Errorf("Acos(%g) = %g, want %g\n", vf[i]/10, f, acos[i])
}
@@ -405,8 +404,12 @@ func TestSinh(t *testing.T) {
func TestSqrt(t *testing.T) {
for i := 0; i < len(vf); i++ {
a := Fabs(vf[i])
- if f := Sqrt(a); !veryclose(sqrt[i], f) {
- t.Errorf("Sqrt(%g) = %g, want %g\n", a, f, floor[i])
+ if f := SqrtGo(a); sqrt[i] != f {
+ t.Errorf("sqrtGo(%g) = %g, want %g\n", a, f, sqrt[i])
+ }
+ a = Fabs(vf[i])
+ if f := Sqrt(a); sqrt[i] != f {
+ t.Errorf("Sqrt(%g) = %g, want %g\n", a, f, sqrt[i])
}
}
}
@@ -430,7 +433,7 @@ func TestTanh(t *testing.T) {
func TestHypot(t *testing.T) {
for i := 0; i < len(vf); i++ {
a := Fabs(tanh[i] * Sqrt(2))
- if f := Hypot(tanh[i], tanh[i]); !veryclose(a, f) {
+ if f := Hypot(tanh[i], tanh[i]); a != f {
t.Errorf("Hypot(%g, %g) = %g, want %g\n", tanh[i], tanh[i], f, a)
}
}
diff --git a/src/pkg/math/pow10.go b/src/pkg/math/pow10.go
index 99b318e78f..4835f6dcef 100644
--- a/src/pkg/math/pow10.go
+++ b/src/pkg/math/pow10.go
@@ -15,7 +15,7 @@ package math
var pow10tab [70]float64
-// Pow10 returns 10**x, the base-10 exponential of x.
+// Pow10 returns 10**e, the base-10 exponential of e.
func Pow10(e int) float64 {
if e < 0 {
return 1 / Pow10(-e)
diff --git a/src/pkg/math/sqrt_test.go b/src/pkg/math/sqrt_test.go
new file mode 100644
index 0000000000..84cbc169e8
--- /dev/null
+++ b/src/pkg/math/sqrt_test.go
@@ -0,0 +1,9 @@
+// Copyright 2010 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
+
+// Make sqrtGo available for testing.
+
+func SqrtGo(x float64) float64 { return sqrtGo(x) }