diff --git a/libraries/stdlib/common/src/kotlin/MathH.kt b/libraries/stdlib/common/src/kotlin/MathH.kt index 7f2ce574192..5aa9682c6d3 100644 --- a/libraries/stdlib/common/src/kotlin/MathH.kt +++ b/libraries/stdlib/common/src/kotlin/MathH.kt @@ -20,7 +20,7 @@ public const val PI: Double = 3.141592653589793 @SinceKotlin("1.2") public const val E: Double = 2.718281828459045 -// ================ Double Math ======================================== +// region ================ Double Math ======================================== /** Computes the sine of the angle [x] given in radians. * @@ -477,10 +477,11 @@ public expect fun Double.roundToInt(): Int @SinceKotlin("1.2") public expect fun Double.roundToLong(): Long +// endregion -// ================ Float Math ======================================== +// region ================ Float Math ======================================== /** Computes the sine of the angle [x] given in radians. * @@ -906,6 +907,9 @@ public expect fun Float.roundToInt(): Int public expect fun Float.roundToLong(): Long +// endregion + +// region ================ Integer Math ======================================== /** @@ -997,5 +1001,4 @@ public expect val Long.absoluteValue: Long public expect val Long.sign: Int - - +// endregion diff --git a/libraries/stdlib/js/src/kotlin/math.kt b/libraries/stdlib/js/src/kotlin/math.kt index 995ed8518b2..bf9aa1b3c8e 100644 --- a/libraries/stdlib/js/src/kotlin/math.kt +++ b/libraries/stdlib/js/src/kotlin/math.kt @@ -10,7 +10,7 @@ import kotlin.internal.InlineOnly import kotlin.js.Math as nativeMath -// ================ Double Math ======================================== +// region ================ Double Math ======================================== /** Computes the sine of the angle [x] given in radians. * @@ -543,10 +543,11 @@ public actual fun Double.roundToLong(): Long = when { else -> nativeMath.round(this).unsafeCast().toLong() } +// endregion -// ================ Float Math ======================================== +// region ================ Float Math ======================================== /** Computes the sine of the angle [x] given in radians. * @@ -1010,6 +1011,9 @@ public actual inline fun Float.roundToInt(): Int = toDouble().roundToInt() public actual inline fun Float.roundToLong(): Long = toDouble().roundToLong() +// endregion + +// region ================ Integer Math ======================================== /** @@ -1116,3 +1120,4 @@ public actual val Long.sign: Int get() = when { } +// endregion diff --git a/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt index 31c84106c95..d207cca5c9b 100644 --- a/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt @@ -36,7 +36,7 @@ private object Constants { } -// ================ Double Math ======================================== +// region ================ Double Math ======================================== /** Computes the sine of the angle [x] given in radians. * @@ -619,8 +619,11 @@ public actual fun Double.roundToInt(): Int = when { public actual fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) +// endregion -// ================ Float Math ======================================== + + +// region ================ Float Math ======================================== /** Computes the sine of the angle [x] given in radians. * @@ -1142,8 +1145,10 @@ public actual fun Float.roundToInt(): Int = public actual fun Float.roundToLong(): Long = toDouble().roundToLong() +// endregion + +// region ================ Integer Math ======================================== -// ================== Integer math functions ===================================== /** * Returns the absolute value of the given value [n]. @@ -1249,3 +1254,5 @@ public actual val Long.sign: Int get() = when { else -> 0 } + +// endregion