diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/math/math.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/math/math.kt index f23b74ee81d..d7243275604 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/math/math.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/math/math.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.math @@ -433,8 +433,8 @@ public actual fun Double.pow(n: Int): Double = pow(n.toDouble()) * `q = round(this / other)`. * * Special cases: - * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. - * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. + * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. + * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. * * @see round */ @@ -816,7 +816,7 @@ external public actual fun ln(x: Float): Float /** * Computes the common logarithm (base 10) of the value [x]. * - * @see [ln] actual function for special cases. + * @see [ln] function for special cases. */ @SinceKotlin("1.2") @GCUnsafeCall("Kotlin_math_log10f") @@ -825,14 +825,14 @@ external public actual fun log10(x: Float): Float /** * Computes the binary logarithm (base 2) of the value [x]. * - * @see [ln] actual function for special cases. + * @see [ln] function for special cases. */ @SinceKotlin("1.2") @GCUnsafeCall("Kotlin_math_log2f") external public actual fun log2(x: Float): Float /** - * Computes `ln(a + 1)`. + * Computes `ln(x + 1)`. * * This function can be implemented to produce more precise result for [x] near zero. * @@ -1000,8 +1000,8 @@ public actual fun Float.pow(n: Int): Float = pow(n.toFloat()) * `q = round(this / other)`. * * Special cases: - * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. - * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. + * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. + * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. * * @see round */ @@ -1015,7 +1015,7 @@ external public fun Float.IEEErem(divisor: Float): Float * Special cases: * - `NaN.absoluteValue` is `NaN` * - * @see abs actual function + * @see abs function */ @SinceKotlin("1.2") public actual val Float.absoluteValue: Float @@ -1048,6 +1048,16 @@ external public actual fun Float.withSign(sign: Float): Float @SinceKotlin("1.2") public actual fun Float.withSign(sign: Int): Float = withSign(sign.toFloat()) +/** + * Returns the ulp of this value. + * + * An ulp is a positive distance between this value and the next nearest [Float] value larger in magnitude. + * + * Special Cases: + * - `NaN.ulp` is `NaN` + * - `x.ulp` is `+Inf` when `x` is `+Inf` or `-Inf` + * - `0.0.ulp` is `Float.MIN_VALUE` + */ @SinceKotlin("1.2") public val Float.ulp: Float get() = when { @@ -1212,7 +1222,7 @@ public actual fun max(a: Long, b: Long): Long = if (a > b) a else b * Special cases: * - `Long.MIN_VALUE.absoluteValue` is `Long.MIN_VALUE` due to an overflow * - * @see abs actual function + * @see abs function */ @SinceKotlin("1.2") public actual val Long.absoluteValue: Long diff --git a/libraries/stdlib/common/src/kotlin/MathH.kt b/libraries/stdlib/common/src/kotlin/MathH.kt index 29995bba191..822e303358a 100644 --- a/libraries/stdlib/common/src/kotlin/MathH.kt +++ b/libraries/stdlib/common/src/kotlin/MathH.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -733,7 +733,7 @@ public expect fun log10(x: Float): Float public expect fun log2(x: Float): Float /** - * Computes `ln(a + 1)`. + * Computes `ln(x + 1)`. * * This function can be implemented to produce more precise result for [x] near zero. * diff --git a/libraries/stdlib/js/src/kotlin/math.kt b/libraries/stdlib/js/src/kotlin/math.kt index eb31b91afd7..5bfcf44ac2a 100644 --- a/libraries/stdlib/js/src/kotlin/math.kt +++ b/libraries/stdlib/js/src/kotlin/math.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.math @@ -808,7 +808,7 @@ public actual inline fun log10(x: Float): Float = nativeLog10(x.toDouble()).toFl public actual inline fun log2(x: Float): Float = nativeLog2(x.toDouble()).toFloat() /** - * Computes `ln(a + 1)`. + * Computes `ln(x + 1)`. * * This function can be implemented to produce more precise result for [x] near zero. * diff --git a/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt index 2f415a5f3f6..84794c08f74 100644 --- a/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -514,8 +514,8 @@ public actual inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toD * `q = round(this / other)`. * * Special cases: - * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. - * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. + * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. + * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. * * @see round */ @@ -898,7 +898,7 @@ public actual inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()) public actual fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat() /** - * Computes `ln(a + 1)`. + * Computes `ln(x + 1)`. * * This function can be implemented to produce more precise result for [x] near zero. * @@ -1060,8 +1060,8 @@ public actual inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble * `q = round(this / other)`. * * Special cases: - * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. - * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. + * - `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. + * - `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. * * @see round */