Skip to content

Commit fdbc66d

Browse files
committed
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Alan Donovan <[email protected]>
1 parent c71cbd5 commit fdbc66d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

api/go1.21.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pkg maps, func Equal[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$3 }, $2
345345
pkg maps, func EqualFunc[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$4 }, $2 comparable, $3 interface{}, $4 interface{}]($0, $1, func($3, $4) bool) bool #57436
346346
pkg maps, func Keys[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) []$1 #57436
347347
pkg maps, func Values[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) []$2 #57436
348-
pkg math/big, method (*Int) ToFloat64() (float64, Accuracy) #56984
348+
pkg math/big, method (*Int) Float64() (float64, Accuracy) #56984
349349
pkg net/http, method (*ProtocolError) Is(error) bool #41198
350350
pkg net/http, method (*ResponseController) EnableFullDuplex() error #57786
351351
pkg net/http, var ErrSchemeMismatch error #44855

doc/go1.21.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
662662
<dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
663663
<dd>
664664
<p><!-- https://go.dev/issue/56984, CL 453115 -->
665-
The new <a href="/pkg/math/big/#Int.ToFloat64"><code>Int.ToFloat64</code></a>
665+
The new <a href="/pkg/math/big/#Int.Float64"><code>Int.Float64</code></a>
666666
method returns the nearest floating-point value to a
667667
multi-precision integer, along with an indication of any
668668
rounding that occurred.

src/math/big/int.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ func (x *Int) IsUint64() bool {
450450
return !x.neg && len(x.abs) <= 64/_W
451451
}
452452

453-
// ToFloat64 returns the float64 value nearest x,
453+
// Float64 returns the float64 value nearest x,
454454
// and an indication of any rounding that occurred.
455-
func (x *Int) ToFloat64() (float64, Accuracy) {
455+
func (x *Int) Float64() (float64, Accuracy) {
456456
n := x.abs.bitLen() // NB: still uses slow crypto impl!
457457
if n == 0 {
458458
return 0.0, Exact

src/math/big/int_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,7 @@ func TestNewIntAllocs(t *testing.T) {
19521952
}
19531953
}
19541954

1955-
func TestToFloat64(t *testing.T) {
1955+
func TestFloat64(t *testing.T) {
19561956
for _, test := range []struct {
19571957
istr string
19581958
f float64
@@ -1988,7 +1988,7 @@ func TestToFloat64(t *testing.T) {
19881988
}
19891989

19901990
// Test against expectation.
1991-
f, acc := i.ToFloat64()
1991+
f, acc := i.Float64()
19921992
if f != test.f || acc != test.acc {
19931993
t.Errorf("%s: got %f (%s); want %f (%s)", test.istr, f, acc, test.f, test.acc)
19941994
}

0 commit comments

Comments
 (0)