Skip to content

Commit bf14663

Browse files
ianlancetaylorgopherbot
authored andcommitted
Revert "math: add Compare and Compare32"
This reverts CL 467515. Now that we have cmp.Compare, we don't need math.Compare or math.Compare32 after all. For #56491 Fixes #60519 Change-Id: I8ed33464adfc6d69bd6b328edb26aa2ee3d234d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/499416 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Eli Bendersky <[email protected]>
1 parent e946f0e commit bf14663

File tree

3 files changed

+0
-149
lines changed

3 files changed

+0
-149
lines changed

api/next/56491.txt

-2
This file was deleted.

src/math/all_test.go

-94
Original file line numberDiff line numberDiff line change
@@ -2094,67 +2094,6 @@ var sqrt32 = []float32{
20942094
-5.0106036182710749e+00,
20952095
}
20962096

2097-
type compareTest[F float32 | float64] struct {
2098-
x, y F
2099-
want int
2100-
}
2101-
2102-
func compareCasesFloat64() []compareTest[float64] {
2103-
zero, nan, inf := 0.0, NaN(), Inf(0)
2104-
2105-
// construct -NaN manually from its bit representation,
2106-
// since IEEE doesn't mandate negate(NaN) change the sign bit
2107-
unegnan := Float64bits(nan)
2108-
unegnan ^= 1 << 63
2109-
negnan := Float64frombits(unegnan)
2110-
return []compareTest[float64]{
2111-
{negnan, -inf, -1},
2112-
{-inf, negnan, 1},
2113-
{-inf, -Pi, -1},
2114-
{-Pi, -inf, 1},
2115-
{-Pi, -zero, -1},
2116-
{-zero, -Pi, 1},
2117-
{-zero, 0, -1},
2118-
{0, -zero, 1},
2119-
{0, Pi, -1},
2120-
{Pi, 0, 1},
2121-
{Pi, inf, -1},
2122-
{inf, Pi, 1},
2123-
{inf, nan, -1},
2124-
{nan, inf, 1},
2125-
{Pi, Pi, 0},
2126-
{negnan, negnan, 0},
2127-
}
2128-
}
2129-
2130-
func compareCasesFloat32() []compareTest[float32] {
2131-
zero, nan, inf := float32(0.0), float32(NaN()), float32(Inf(0))
2132-
2133-
// construct -NaN manually from its bit representation,
2134-
// since IEEE doesn't mandate negate(NaN) change the sign bit
2135-
unegnan := Float32bits(nan)
2136-
unegnan ^= 1 << 31
2137-
negnan := Float32frombits(unegnan)
2138-
return []compareTest[float32]{
2139-
{negnan, -inf, -1},
2140-
{-inf, negnan, 1},
2141-
{-inf, -Pi, -1},
2142-
{-Pi, -inf, 1},
2143-
{-Pi, -zero, -1},
2144-
{-zero, -Pi, 1},
2145-
{-zero, 0, -1},
2146-
{0, -zero, 1},
2147-
{0, Pi, -1},
2148-
{Pi, 0, 1},
2149-
{Pi, inf, -1},
2150-
{inf, Pi, 1},
2151-
{inf, nan, -1},
2152-
{nan, inf, 1},
2153-
{Pi, Pi, 0},
2154-
{negnan, negnan, 0},
2155-
}
2156-
}
2157-
21582097
func tolerance(a, b, e float64) bool {
21592098
// Multiplying by e here can underflow denormal values to zero.
21602099
// Check a==b so that at least if a and b are small and identical
@@ -2322,22 +2261,6 @@ func TestCeil(t *testing.T) {
23222261
}
23232262
}
23242263

2325-
func TestCompare(t *testing.T) {
2326-
// -NaN < -∞ < -3.14 < -0 < 0 < 3.14 < ∞ < NaN
2327-
for _, c := range compareCasesFloat64() {
2328-
cmp := Compare(c.x, c.y)
2329-
if cmp != c.want {
2330-
t.Errorf("Compare(%v, %v) = %d, want %v", c.x, c.y, cmp, c.want)
2331-
}
2332-
}
2333-
for _, c := range compareCasesFloat32() {
2334-
cmp := Compare32(c.x, c.y)
2335-
if cmp != c.want {
2336-
t.Errorf("Compare32(%v, %v) = %d, want %v", c.x, c.y, cmp, c.want)
2337-
}
2338-
}
2339-
}
2340-
23412264
func TestCopysign(t *testing.T) {
23422265
for i := 0; i < len(vf); i++ {
23432266
if f := Copysign(vf[i], -1); copysign[i] != f {
@@ -3397,23 +3320,6 @@ func BenchmarkCeil(b *testing.B) {
33973320
GlobalF = x
33983321
}
33993322

3400-
func BenchmarkCompare(b *testing.B) {
3401-
x := 0
3402-
for i := 0; i < b.N; i++ {
3403-
x = Compare(GlobalF, 1.5)
3404-
}
3405-
GlobalI = x
3406-
}
3407-
3408-
func BenchmarkCompare32(b *testing.B) {
3409-
x := 0
3410-
globalF32 := float32(GlobalF)
3411-
for i := 0; i < b.N; i++ {
3412-
x = Compare32(globalF32, 1.5)
3413-
}
3414-
GlobalI = x
3415-
}
3416-
34173323
var copysignNeg = -1.0
34183324

34193325
func BenchmarkCopysign(b *testing.B) {

src/math/compare.go

-53
This file was deleted.

0 commit comments

Comments
 (0)