]> Cypherpunks repositories - gostls13.git/commit
math/big: add support for underscores '_' in numbers
authorRobert Griesemer <gri@golang.org>
Fri, 8 Mar 2019 01:44:50 +0000 (17:44 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 12 Mar 2019 22:58:58 +0000 (22:58 +0000)
commitcfa93ba51fb62252633c62ddc9351d56c18ce018
tree1f59cff889f89198469b7d11a1d916458d359c5f
parentc4078a1998657709848e18e82a1b9f2cccac05c7
math/big: add support for underscores '_' in numbers

The primary change is in nat.scan which now accepts underscores for base 0.
While at it, streamlined error handling in that function as well.
Also, improved the corresponding test significantly by checking the
expected result values also in case of scan errors.

The second major change is in scanExponent which now accepts underscores when
the new sepOk argument is set. While at it, essentially rewrote that
function to match error and underscore handling of nat.scan more closely.
Added a new test for scanExponent which until now was only tested
indirectly.

Finally, updated the documentation for several functions and added many
new test cases to clients of nat.scan.

A major portion of this CL is due to much better test coverage.

Updates #28493.

Change-Id: I7f17b361b633fbe6c798619d891bd5e0a045b5c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/166157
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
src/math/big/floatconv.go
src/math/big/floatconv_test.go
src/math/big/int.go
src/math/big/intconv_test.go
src/math/big/natconv.go
src/math/big/natconv_test.go
src/math/big/ratconv.go
src/math/big/ratconv_test.go