Remove implementations of conversions from UByte/UShort to Float/Double

This commit is contained in:
Abduqodiri Qurbonzoda
2019-03-07 19:06:49 +03:00
parent d12e5ddafc
commit 82002e5e73
5 changed files with 4 additions and 62 deletions
@@ -299,24 +299,3 @@ public inline fun Int.toUByte(): UByte = UByte(this.toByte())
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun Long.toUByte(): UByte = UByte(this.toByte())
/**
* Converts this [Float] value to [UByte].
*
* The fractional part, if any, is rounded down.
* Returns zero if this `Float` value is negative or `NaN`, [UByte.MAX_VALUE] if it's bigger than `UByte.MAX_VALUE`.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun Float.toUByte(): UByte = doubleToUByte(this.toDouble())
/**
* Converts this [Double] value to [UByte].
*
* The fractional part, if any, is rounded down.
* Returns zero if this `Double` value is negative or `NaN`, [UByte.MAX_VALUE] if it's bigger than `UByte.MAX_VALUE`.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun Double.toUByte(): UByte = doubleToUByte(this)
@@ -300,24 +300,3 @@ public inline fun Int.toUShort(): UShort = UShort(this.toShort())
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun Long.toUShort(): UShort = UShort(this.toShort())
/**
* Converts this [Float] value to [UShort].
*
* The fractional part, if any, is rounded down.
* Returns zero if this `Float` value is negative or `NaN`, [UShort.MAX_VALUE] if it's bigger than `UShort.MAX_VALUE`.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun Float.toUShort(): UShort = doubleToUShort(this.toDouble())
/**
* Converts this [Double] value to [UShort].
*
* The fractional part, if any, is rounded down.
* Returns zero if this `Double` value is negative or `NaN`, [UShort.MAX_VALUE] if it's bigger than `UShort.MAX_VALUE`.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun Double.toUShort(): UShort = doubleToUShort(this)
@@ -62,23 +62,6 @@ internal fun ulongRemainder(v1: ULong, v2: ULong): ULong {
return ULong(rem - if (ULong(rem) >= ULong(divisor)) divisor else 0)
}
@PublishedApi
internal fun doubleToUByte(v: Double): UByte = when {
v.isNaN() -> 0u
v <= UByte.MIN_VALUE.toDouble() -> UByte.MIN_VALUE
v >= UByte.MAX_VALUE.toDouble() -> UByte.MAX_VALUE
else -> v.toInt().toUByte()
}
@PublishedApi
internal fun doubleToUShort(v: Double): UShort = when {
v.isNaN() -> 0u
v <= UShort.MIN_VALUE.toDouble() -> UShort.MIN_VALUE
v >= UShort.MAX_VALUE.toDouble() -> UShort.MAX_VALUE
else -> v.toInt().toUShort()
}
@PublishedApi
internal fun doubleToUInt(v: Double): UInt = when {
v.isNaN() -> 0u