1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:20:02 -07:00

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>
This commit is contained in:
Robert Griesemer 2015-04-08 12:28:44 -07:00
parent 514eb4aa54
commit b28802d2f1
2 changed files with 8 additions and 0 deletions

View File

@ -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.

View File

@ -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 {