File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -210,10 +210,14 @@ func make(t Type, size ...IntegerType) Type
210
210
211
211
// The max built-in function returns the largest value of a fixed number of
212
212
// arguments of [cmp.Ordered] types. There must be at least one argument.
213
+ // If T is a floating-point type and any of the arguments are NaNs,
214
+ // max will return NaN.
213
215
func max [T cmp.Ordered ](x T , y ... T ) T
214
216
215
217
// The min built-in function returns the smallest value of a fixed number of
216
218
// arguments of [cmp.Ordered] types. There must be at least one argument.
219
+ // If T is a floating-point type and any of the arguments are NaNs,
220
+ // min will return NaN.
217
221
func min [T cmp.Ordered ](x T , y ... T ) T
218
222
219
223
// The new built-in function allocates memory. The first argument is a type,
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ package cmp
10
10
// that supports the operators < <= >= >.
11
11
// If future releases of Go add new ordered types,
12
12
// this constraint will be modified to include them.
13
+ //
14
+ // Note that floating-point types may contain NaN ("not-a-number") values.
15
+ // An operator such as == or < will always report false when
16
+ // comparing a NaN value with any other value, NaN or not.
17
+ // See the [Compare] function for a consistent way to compare NaN values.
13
18
type Ordered interface {
14
19
~ int | ~ int8 | ~ int16 | ~ int32 | ~ int64 |
15
20
~ uint | ~ uint8 | ~ uint16 | ~ uint32 | ~ uint64 | ~ uintptr |
You can’t perform that action at this time.
0 commit comments