From 940c3c81ad4ba72b4b63ac484f50c6e2db3398e8 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Fri, 5 Jan 2024 17:13:37 +0000 Subject: [PATCH] KT-64361 delegate Int/Long::sign to methods from Java stdlib Merge-request: KT-MR-13708 Merged-by: Filipp Zhinkin --- libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt index 84794c08f74..95372010301 100644 --- a/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt @@ -1228,11 +1228,7 @@ public actual inline val Int.absoluteValue: Int get() = nativeMath.abs(this) * - `1` if the value is positive */ @SinceKotlin("1.2") -public actual val Int.sign: Int get() = when { - this < 0 -> -1 - this > 0 -> 1 - else -> 0 -} +public actual val Int.sign: Int get() = Integer.signum(this) @@ -1281,11 +1277,7 @@ public actual inline val Long.absoluteValue: Long get() = nativeMath.abs(this) * - `1` if the value is positive */ @SinceKotlin("1.2") -public actual val Long.sign: Int get() = when { - this < 0 -> -1 - this > 0 -> 1 - else -> 0 -} +public actual val Long.sign: Int get() = java.lang.Long.signum(this) // endregion