diff options
| author | Robert Griesemer <gri@golang.org> | 2015-03-30 18:11:48 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2015-03-31 23:05:31 +0000 |
| commit | fa85a7206d46dc30d59cfd4e882b58a59a0a3d88 (patch) | |
| tree | 1d46eee25ee0a710c37e8302b657421775b13dd4 /src/math/big/floatconv.go | |
| parent | 67426a8a9eabd6d859e42ca799eab6c1aa0d616a (diff) | |
| download | go-fa85a7206d46dc30d59cfd4e882b58a59a0a3d88.tar.xz | |
math/big: remove NaN support - just not worth it
NaNs make the API more complicated for no real good reasons.
There are few operations that produce NaNs with IEEE arithmetic,
there's no need to copy the behavior. It's easy to test for these
scenarios and avoid them (on the other hand, it's not easy to test
for overflow or underflow, so we want to keep +/-Inf).
Also:
- renamed IsNeg -> Signbit (clearer, especially for x == -0)
- removed IsZero (Sign() == 0 is sufficient and efficient)
- removed IsFinite (now same as !IsInf)
Change-Id: I3f3b4445c325d9bbb1bf46ce2e298a6aeb498e07
Reviewed-on: https://go-review.googlesource.com/8280
Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/math/big/floatconv.go')
| -rw-r--r-- | src/math/big/floatconv.go | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/math/big/floatconv.go b/src/math/big/floatconv.go index 8905718d29..7dc9a2800c 100644 --- a/src/math/big/floatconv.go +++ b/src/math/big/floatconv.go @@ -73,10 +73,8 @@ func (z *Float) Scan(r io.ByteScanner, base int) (f *Float, b int, err error) { prec = 64 } - // NaNs ignore sign, mantissa, and exponent so we can set - // them below while having a valid value for z in case of - // errors. - z.SetNaN() + // A reasonable value in case of an error. + z.form = zero // sign z.neg, err = scanSign(r) @@ -260,11 +258,6 @@ func (x *Float) Append(buf []byte, format byte, prec int) []byte { return append(buf, "Inf"...) } - // NaN - if x.IsNaN() { - return append(buf, "NaN"...) - } - // easy formats switch format { case 'b': |
