KT-64361 delegate Int/Long::sign to methods from Java stdlib

Merge-request: KT-MR-13708
Merged-by: Filipp Zhinkin <filipp.zhinkin@jetbrains.com>
This commit is contained in:
Filipp Zhinkin
2024-01-05 17:13:37 +00:00
committed by Space Team
parent 1b7d1dd08a
commit 940c3c81ad
@@ -1228,11 +1228,7 @@ public actual inline val Int.absoluteValue: Int get() = nativeMath.abs(this)
* - `1` if the value is positive * - `1` if the value is positive
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public actual val Int.sign: Int get() = when { public actual val Int.sign: Int get() = Integer.signum(this)
this < 0 -> -1
this > 0 -> 1
else -> 0
}
@@ -1281,11 +1277,7 @@ public actual inline val Long.absoluteValue: Long get() = nativeMath.abs(this)
* - `1` if the value is positive * - `1` if the value is positive
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public actual val Long.sign: Int get() = when { public actual val Long.sign: Int get() = java.lang.Long.signum(this)
this < 0 -> -1
this > 0 -> 1
else -> 0
}
// endregion // endregion