X Tutup
Skip to content

Commit b28802d

Browse files
committed
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>
1 parent 514eb4a commit b28802d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/math/big/float.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ type ErrNaN struct {
7171
msg string
7272
}
7373

74+
// ErrNan implements the error interface.
75+
func (err ErrNaN) Error() string {
76+
return err.msg
77+
}
78+
7479
// NewFloat allocates and returns a new Float set to x,
7580
// with precision 53 and rounding mode ToNearestEven.
7681
// NewFloat panics with ErrNaN if x is a NaN.

src/math/big/float_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212
"testing"
1313
)
1414

15+
// Verify that ErrNaN implements the error interface.
16+
var _ error = ErrNaN{}
17+
1518
func (x *Float) uint64() uint64 {
1619
u, acc := x.Uint64()
1720
if acc != Exact {

0 commit comments

Comments
 (0)
X Tutup