aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2015-04-08 12:28:44 -0700
committerRobert Griesemer <gri@golang.org>2015-04-08 19:47:39 +0000
commitb28802d2f1ba9ef49fc3608d7026a524a98bdddb (patch)
treedb625dd87f94eb4334e661b8fda664bc09154144 /src
parent514eb4aa542f6989630b0cda290a77be3bc0fb4c (diff)
downloadgo-b28802d2f1ba9ef49fc3608d7026a524a98bdddb.tar.xz
math/big: make ErrNaN actually implement the error interface (oversight)
There was no way to get to the error message before. Change-Id: I4aa9d3d9f468c33f9996295bafcbed097de0389f Reviewed-on: https://go-review.googlesource.com/8660 Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/math/big/float.go5
-rw-r--r--src/math/big/float_test.go3
2 files changed, 8 insertions, 0 deletions
diff --git a/src/math/big/float.go b/src/math/big/float.go
index ed55e8e513..35ad2567e7 100644
--- a/src/math/big/float.go
+++ b/src/math/big/float.go
@@ -71,6 +71,11 @@ type ErrNaN struct {
msg string
}
+// ErrNan implements the error interface.
+func (err ErrNaN) Error() string {
+ return err.msg
+}
+
// NewFloat allocates and returns a new Float set to x,
// with precision 53 and rounding mode ToNearestEven.
// NewFloat panics with ErrNaN if x is a NaN.
diff --git a/src/math/big/float_test.go b/src/math/big/float_test.go
index 2a48ec4465..5b5a0247b1 100644
--- a/src/math/big/float_test.go
+++ b/src/math/big/float_test.go
@@ -12,6 +12,9 @@ import (
"testing"
)
+// Verify that ErrNaN implements the error interface.
+var _ error = ErrNaN{}
+
func (x *Float) uint64() uint64 {
u, acc := x.Uint64()
if acc != Exact {