diff options
| author | Than McIntosh <thanm@google.com> | 2023-02-10 14:39:20 +0000 |
|---|---|---|
| committer | Than McIntosh <thanm@google.com> | 2023-02-10 18:08:07 +0000 |
| commit | ac8a97ac9e5de94d1c0e830299ce6487cbbfd3f6 (patch) | |
| tree | b69a9fe7da1662df65c4319b238186c72c480d81 /src/math/compare.go | |
| parent | aa5b22552ac353c79ad1e8b6202ab4fa131338ef (diff) | |
| download | go-ac8a97ac9e5de94d1c0e830299ce6487cbbfd3f6.tar.xz | |
Revert "math: add Compare and Compare32"
This reverts CL 459435.
Reason for revert: Tests failing on MIPS.
Change-Id: I9017bf718ba938df6d6766041555034d55d90b8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/467255
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Akhil Indurti <aindurti@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/math/compare.go')
| -rw-r--r-- | src/math/compare.go | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/math/compare.go b/src/math/compare.go deleted file mode 100644 index 3798110072..0000000000 --- a/src/math/compare.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package math - -func sign[I int32 | int64](a, b I) int { - if a < b { - return -1 - } - if a > b { - return 1 - } - return 0 -} - -// Compare compares a and b such that -// -NaN is ordered before any other value, -// +NaN is ordered after any other value, -// and -0 is ordered before +0. -// In other words, it defines a total order over floats -// (according to the total-ordering predicate in IEEE-754, section 5.10). -// It returns 0 if a == b, -1 if a < b, and +1 if a > b. -func Compare(a, b float64) int { - // Perform a bitwise comparison (a < b) by casting the float64s into an int64s. - x := int64(Float64bits(a)) - y := int64(Float64bits(b)) - - // If a and b are both negative, flip the comparison so that we check a > b. - if x < 0 && y < 0 { - return sign(y, x) - } - return sign(x, y) -} - -// Compare32 compares a and b such that -// -NaN is ordered before any other value, -// +NaN is ordered after any other value, -// and -0 is ordered before +0. -// In other words, it defines a total order over floats -// (according to the total-ordering predicate in IEEE-754, section 5.10). -// It returns 0 if a == b, -1 if a < b, and +1 if a > b. -func Compare32(a, b float32) int { - // Perform a bitwise comparison (a < b) by casting the float32s into an int32s. - x := int32(Float32bits(a)) - y := int32(Float32bits(b)) - - // If a and b are both negative, flip the comparison so that we check a > b. - if x < 0 && y < 0 { - return sign(y, x) - } - return sign(x, y) -} |
