diff options
author | Robert Griesemer <gri@golang.org> | 2015-05-28 17:38:05 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2015-05-29 17:11:43 +0000 |
commit | a63b1806aa7484d744e79cd2f6d8e3bf73c4092c (patch) | |
tree | 4a03914612fb69dfd9725860d9cd3f9128c1fb7b /src/math/big/float.go | |
parent | 9b3d9230aac0e8433add721a67f22ad6c27267ed (diff) | |
download | go-git-a63b1806aa7484d744e79cd2f6d8e3bf73c4092c.tar.gz |
math/big: remove (*Float).Scan, ScanFloat; more robust (*Float).Parse
- (*Float).Scan conflicted with fmt.Scanner.Scan; it was also only used
internally. Removed it, as well as the companion ScanFloat function.
- (*Float).Parse (and thus ParseFloat) can now also parse infinities.
As a result, more code could be simplified.
- Fixed a bug in rounding (round may implicitly be called for infinite
values). Found via existing test cases, after simplifying some code.
- Added more test cases.
Fixes issue #10938.
Change-Id: I1df97821654f034965ba8b82b272e52e6dc427f1
Reviewed-on: https://go-review.googlesource.com/10498
Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/math/big/float.go')
-rw-r--r-- | src/math/big/float.go | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/math/big/float.go b/src/math/big/float.go index dff40545d5..b13fea6a6a 100644 --- a/src/math/big/float.go +++ b/src/math/big/float.go @@ -381,14 +381,11 @@ func (x *Float) validate() { func (z *Float) round(sbit uint) { if debugFloat { z.validate() - if z.form > finite { - panic(fmt.Sprintf("round called for non-finite value %s", z)) - } } - // z.form <= finite z.acc = Exact - if z.form == zero { + if z.form != finite { + // ±0 or ±Inf => nothing left to do return } // z.form == finite && len(z.mant) > 0 |