diff options
Diffstat (limited to 'src/cmp/cmp.go')
-rw-r--r-- | src/cmp/cmp.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/cmp/cmp.go b/src/cmp/cmp.go index 4d1af6a98c4..a13834c3985 100644 --- a/src/cmp/cmp.go +++ b/src/cmp/cmp.go @@ -40,13 +40,19 @@ func Less[T Ordered](x, y T) bool { func Compare[T Ordered](x, y T) int { xNaN := isNaN(x) yNaN := isNaN(y) - if xNaN && yNaN { - return 0 + if xNaN { + if yNaN { + return 0 + } + return -1 + } + if yNaN { + return +1 } - if xNaN || x < y { + if x < y { return -1 } - if yNaN || x > y { + if x > y { return +1 } return 0 |