aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2023-06-01 18:29:57 -0400
committerAlan Donovan <adonovan@google.com>2023-06-02 14:22:24 +0000
commitfdbc66d6ddd605c49c13261e423bb8a862eca3a2 (patch)
tree914cb34a6c157d6ec8e143fd36f16dca7b344663 /src
parentc71cbd544e3da139badd4c03612af41b63711705 (diff)
downloadgo-fdbc66d6ddd605c49c13261e423bb8a862eca3a2.tar.xz
math/big: rename Int.ToFloat64 to Float64
The "To" prefix was a relic of the first draft that I failed to make consistent with the unprefixed name used in the proposal. Fortunately iant spotted it during the API audit. Updates #56984 Updates #60560 Change-Id: Ifa6eeddf6dd5f0637c0568e383f9a4bef88b10f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/500116 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/math/big/int.go4
-rw-r--r--src/math/big/int_test.go4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/math/big/int.go b/src/math/big/int.go
index c9788beebd..2cc3d7b441 100644
--- a/src/math/big/int.go
+++ b/src/math/big/int.go
@@ -450,9 +450,9 @@ func (x *Int) IsUint64() bool {
return !x.neg && len(x.abs) <= 64/_W
}
-// ToFloat64 returns the float64 value nearest x,
+// Float64 returns the float64 value nearest x,
// and an indication of any rounding that occurred.
-func (x *Int) ToFloat64() (float64, Accuracy) {
+func (x *Int) Float64() (float64, Accuracy) {
n := x.abs.bitLen() // NB: still uses slow crypto impl!
if n == 0 {
return 0.0, Exact
diff --git a/src/math/big/int_test.go b/src/math/big/int_test.go
index dfbc17242d..cb964a43cd 100644
--- a/src/math/big/int_test.go
+++ b/src/math/big/int_test.go
@@ -1952,7 +1952,7 @@ func TestNewIntAllocs(t *testing.T) {
}
}
-func TestToFloat64(t *testing.T) {
+func TestFloat64(t *testing.T) {
for _, test := range []struct {
istr string
f float64
@@ -1988,7 +1988,7 @@ func TestToFloat64(t *testing.T) {
}
// Test against expectation.
- f, acc := i.ToFloat64()
+ f, acc := i.Float64()
if f != test.f || acc != test.acc {
t.Errorf("%s: got %f (%s); want %f (%s)", test.istr, f, acc, test.f, test.acc)
}