Document NaN propagation in top-level minOf/maxOf functions

This commit is contained in:
Ilya Gorbunov
2020-05-22 16:01:47 +03:00
parent d19f9ee0c5
commit e2c3455445
6 changed files with 276 additions and 106 deletions
@@ -17,6 +17,7 @@ import kotlin.random.*
/**
* Returns the greater of two values.
*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
@@ -52,6 +53,8 @@ public expect inline fun maxOf(a: Long, b: Long): Long
/**
* Returns the greater of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -59,6 +62,8 @@ public expect inline fun maxOf(a: Float, b: Float): Float
/**
* Returns the greater of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -66,6 +71,8 @@ public expect inline fun maxOf(a: Double, b: Double): Double
/**
* Returns the greater of three values.
*
* If there are multiple equal maximal values, returns the first of them.
*/
@SinceKotlin("1.1")
public expect fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T
@@ -100,6 +107,8 @@ public expect inline fun maxOf(a: Long, b: Long, c: Long): Long
/**
* Returns the greater of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -107,6 +116,8 @@ public expect inline fun maxOf(a: Float, b: Float, c: Float): Float
/**
* Returns the greater of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -114,6 +125,8 @@ public expect inline fun maxOf(a: Double, b: Double, c: Double): Double
/**
* Returns the greater of three values according to the order specified by the given [comparator].
*
* If there are multiple equal maximal values, returns the first of them.
*/
@SinceKotlin("1.1")
public fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
@@ -122,6 +135,7 @@ public fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
/**
* Returns the greater of two values according to the order specified by the given [comparator].
*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
@@ -130,49 +144,57 @@ public fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T {
}
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*
* If there are multiple equal maximal values, returns the first of them.
*/
@SinceKotlin("1.4")
public expect fun <T : Comparable<T>> maxOf(a: T, vararg other: T): T
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public expect fun maxOf(a: Byte, vararg other: Byte): Byte
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public expect fun maxOf(a: Short, vararg other: Short): Short
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public expect fun maxOf(a: Int, vararg other: Int): Int
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public expect fun maxOf(a: Long, vararg other: Long): Long
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public expect fun maxOf(a: Float, vararg other: Float): Float
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public expect fun maxOf(a: Double, vararg other: Double): Double
/**
* Returns the greater of given values according to the order specified by the given [comparator].
* Returns the greater of the given values according to the order specified by the given [comparator].
*
* If there are multiple equal maximal values, returns the first of them.
*/
@SinceKotlin("1.4")
public fun <T> maxOf(a: T, vararg other: T, comparator: Comparator<in T>): T {
@@ -183,6 +205,7 @@ public fun <T> maxOf(a: T, vararg other: T, comparator: Comparator<in T>): T {
/**
* Returns the smaller of two values.
*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
@@ -218,6 +241,8 @@ public expect inline fun minOf(a: Long, b: Long): Long
/**
* Returns the smaller of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -225,6 +250,8 @@ public expect inline fun minOf(a: Float, b: Float): Float
/**
* Returns the smaller of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -232,6 +259,8 @@ public expect inline fun minOf(a: Double, b: Double): Double
/**
* Returns the smaller of three values.
*
* If there are multiple equal minimal values, returns the first of them.
*/
@SinceKotlin("1.1")
public expect fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T
@@ -266,6 +295,8 @@ public expect inline fun minOf(a: Long, b: Long, c: Long): Long
/**
* Returns the smaller of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -273,6 +304,8 @@ public expect inline fun minOf(a: Float, b: Float, c: Float): Float
/**
* Returns the smaller of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@@ -280,6 +313,8 @@ public expect inline fun minOf(a: Double, b: Double, c: Double): Double
/**
* Returns the smaller of three values according to the order specified by the given [comparator].
*
* If there are multiple equal minimal values, returns the first of them.
*/
@SinceKotlin("1.1")
public fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
@@ -288,6 +323,7 @@ public fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
/**
* Returns the smaller of two values according to the order specified by the given [comparator].
*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
@@ -296,49 +332,57 @@ public fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T {
}
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*
* If there are multiple equal minimal values, returns the first of them.
*/
@SinceKotlin("1.4")
public expect fun <T : Comparable<T>> minOf(a: T, vararg other: T): T
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public expect fun minOf(a: Byte, vararg other: Byte): Byte
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public expect fun minOf(a: Short, vararg other: Short): Short
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public expect fun minOf(a: Int, vararg other: Int): Int
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public expect fun minOf(a: Long, vararg other: Long): Long
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public expect fun minOf(a: Float, vararg other: Float): Float
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public expect fun minOf(a: Double, vararg other: Double): Double
/**
* Returns the smaller of given values according to the order specified by the given [comparator].
* Returns the smaller of the given values according to the order specified by the given [comparator].
*
* If there are multiple equal minimal values, returns the first of them.
*/
@SinceKotlin("1.4")
public fun <T> minOf(a: T, vararg other: T, comparator: Comparator<in T>): T {
@@ -92,7 +92,7 @@ public inline fun maxOf(a: UShort, b: UShort, c: UShort): UShort {
}
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -103,7 +103,7 @@ public fun maxOf(a: UInt, vararg other: UInt): UInt {
}
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -114,7 +114,7 @@ public fun maxOf(a: ULong, vararg other: ULong): ULong {
}
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -125,7 +125,7 @@ public fun maxOf(a: UByte, vararg other: UByte): UByte {
}
/**
* Returns the greater of given values.
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -212,7 +212,7 @@ public inline fun minOf(a: UShort, b: UShort, c: UShort): UShort {
}
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -223,7 +223,7 @@ public fun minOf(a: UInt, vararg other: UInt): UInt {
}
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -234,7 +234,7 @@ public fun minOf(a: ULong, vararg other: ULong): ULong {
}
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@@ -245,7 +245,7 @@ public fun minOf(a: UByte, vararg other: UByte): UByte {
}
/**
* Returns the smaller of given values.
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes