aboutsummaryrefslogtreecommitdiff
path: root/src/cmp
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-06-09 19:59:37 -0700
committerGopher Robot <gobot@golang.org>2023-06-11 00:41:42 +0000
commit1fd3cc7cd095377f8a742d55b6c04516b9139b03 (patch)
treeaa097caaeccfaecafdd17fb51f3258753d000f91 /src/cmp
parentfd353a12803863a59e200c917c88cc7fe2f0ade5 (diff)
downloadgo-1fd3cc7cd095377f8a742d55b6c04516b9139b03.tar.gz
go-1fd3cc7cd095377f8a742d55b6c04516b9139b03.zip
cmp, builtin: document NaN behavior
Add notes for cmp.Ordered and builtin.{min,max}. Fixes #60648 Change-Id: I81806af2d9a0613befde3f2bbfbc2720f0726912 Reviewed-on: https://go-review.googlesource.com/c/go/+/502235 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmp')
-rw-r--r--src/cmp/cmp.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmp/cmp.go b/src/cmp/cmp.go
index 3da8ff4570..0fba5c1211 100644
--- a/src/cmp/cmp.go
+++ b/src/cmp/cmp.go
@@ -10,6 +10,11 @@ package cmp
// that supports the operators < <= >= >.
// If future releases of Go add new ordered types,
// this constraint will be modified to include them.
+//
+// Note that floating-point types may contain NaN ("not-a-number") values.
+// An operator such as == or < will always report false when
+// comparing a NaN value with any other value, NaN or not.
+// See the [Compare] function for a consistent way to compare NaN values.
type Ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 |
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |