Implement unsigned/signed conversions
This commit is contained in:
@@ -113,19 +113,19 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
|
||||
/** Inverts the bits in this value. */
|
||||
public fun inv(): UByte = UByte(data.inv())
|
||||
|
||||
public fun toByte(): Byte = TODO()
|
||||
public fun toShort(): Short = TODO()
|
||||
public fun toInt(): Int = TODO()
|
||||
public fun toLong(): Long = TODO()
|
||||
public fun toByte(): Byte = data
|
||||
public fun toShort(): Short = data.toShort() and 0xFF
|
||||
public fun toInt(): Int = data.toInt() and 0xFF
|
||||
public fun toLong(): Long = data.toLong() and 0xFF
|
||||
|
||||
public fun toUByte(): UByte = TODO()
|
||||
public fun toUShort(): UShort = TODO()
|
||||
public fun toUInt(): UInt = TODO()
|
||||
public fun toULong(): ULong = TODO()
|
||||
public fun toUByte(): UByte = this
|
||||
public fun toUShort(): UShort = data.toUShort()
|
||||
public fun toUInt(): UInt = data.toUInt()
|
||||
public fun toULong(): ULong = data.toULong()
|
||||
|
||||
}
|
||||
|
||||
public fun Byte.toUByte(): UByte = UByte(this.toByte())
|
||||
public fun Byte.toUByte(): UByte = UByte(this)
|
||||
public fun Short.toUByte(): UByte = UByte(this.toByte())
|
||||
public fun Int.toUByte(): UByte = UByte(this.toByte())
|
||||
public fun Long.toUByte(): UByte = UByte(this.toByte())
|
||||
|
||||
@@ -117,19 +117,19 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
|
||||
/** Inverts the bits in this value. */
|
||||
public fun inv(): UInt = UInt(data.inv())
|
||||
|
||||
public fun toByte(): Byte = TODO()
|
||||
public fun toShort(): Short = TODO()
|
||||
public fun toInt(): Int = TODO()
|
||||
public fun toLong(): Long = TODO()
|
||||
public fun toByte(): Byte = data.toByte()
|
||||
public fun toShort(): Short = data.toShort()
|
||||
public fun toInt(): Int = data
|
||||
public fun toLong(): Long = data.toLong() and 0xFFFF_FFFF
|
||||
|
||||
public fun toUByte(): UByte = TODO()
|
||||
public fun toUShort(): UShort = TODO()
|
||||
public fun toUInt(): UInt = TODO()
|
||||
public fun toULong(): ULong = TODO()
|
||||
public fun toUByte(): UByte = data.toUByte()
|
||||
public fun toUShort(): UShort = data.toUShort()
|
||||
public fun toUInt(): UInt = this
|
||||
public fun toULong(): ULong = data.toULong()
|
||||
|
||||
}
|
||||
|
||||
public fun Byte.toUInt(): UInt = UInt(this.toInt())
|
||||
public fun Short.toUInt(): UInt = UInt(this.toInt())
|
||||
public fun Int.toUInt(): UInt = UInt(this.toInt())
|
||||
public fun Byte.toUInt(): UInt = UInt(this.toInt() and 0xFF)
|
||||
public fun Short.toUInt(): UInt = UInt(this.toInt() and 0xFFFF)
|
||||
public fun Int.toUInt(): UInt = UInt(this)
|
||||
public fun Long.toUInt(): UInt = UInt(this.toInt())
|
||||
|
||||
@@ -117,19 +117,19 @@ public inline class ULong internal constructor(private val data: Long) : Compara
|
||||
/** Inverts the bits in this value. */
|
||||
public fun inv(): ULong = ULong(data.inv())
|
||||
|
||||
public fun toByte(): Byte = TODO()
|
||||
public fun toShort(): Short = TODO()
|
||||
public fun toInt(): Int = TODO()
|
||||
public fun toLong(): Long = TODO()
|
||||
public fun toByte(): Byte = data.toByte()
|
||||
public fun toShort(): Short = data.toShort()
|
||||
public fun toInt(): Int = data.toInt()
|
||||
public fun toLong(): Long = data
|
||||
|
||||
public fun toUByte(): UByte = TODO()
|
||||
public fun toUShort(): UShort = TODO()
|
||||
public fun toUInt(): UInt = TODO()
|
||||
public fun toULong(): ULong = TODO()
|
||||
public fun toUByte(): UByte = data.toUByte()
|
||||
public fun toUShort(): UShort = data.toUShort()
|
||||
public fun toUInt(): UInt = data.toUInt()
|
||||
public fun toULong(): ULong = this
|
||||
|
||||
}
|
||||
|
||||
public fun Byte.toULong(): ULong = ULong(this.toLong())
|
||||
public fun Short.toULong(): ULong = ULong(this.toLong())
|
||||
public fun Int.toULong(): ULong = ULong(this.toLong())
|
||||
public fun Long.toULong(): ULong = ULong(this.toLong())
|
||||
public fun Byte.toULong(): ULong = ULong(this.toLong() and 0xFF)
|
||||
public fun Short.toULong(): ULong = ULong(this.toLong() and 0xFFFF)
|
||||
public fun Int.toULong(): ULong = ULong(this.toLong() and 0xFFFF_FFFF)
|
||||
public fun Long.toULong(): ULong = ULong(this)
|
||||
|
||||
@@ -113,19 +113,19 @@ public inline class UShort internal constructor(private val data: Short) : Compa
|
||||
/** Inverts the bits in this value. */
|
||||
public fun inv(): UShort = UShort(data.inv())
|
||||
|
||||
public fun toByte(): Byte = TODO()
|
||||
public fun toShort(): Short = TODO()
|
||||
public fun toInt(): Int = TODO()
|
||||
public fun toLong(): Long = TODO()
|
||||
public fun toByte(): Byte = data.toByte()
|
||||
public fun toShort(): Short = data
|
||||
public fun toInt(): Int = data.toInt() and 0xFFFF
|
||||
public fun toLong(): Long = data.toLong() and 0xFFFF
|
||||
|
||||
public fun toUByte(): UByte = TODO()
|
||||
public fun toUShort(): UShort = TODO()
|
||||
public fun toUInt(): UInt = TODO()
|
||||
public fun toULong(): ULong = TODO()
|
||||
public fun toUByte(): UByte = data.toUByte()
|
||||
public fun toUShort(): UShort = this
|
||||
public fun toUInt(): UInt = data.toUInt()
|
||||
public fun toULong(): ULong = data.toULong()
|
||||
|
||||
}
|
||||
|
||||
public fun Byte.toUShort(): UShort = UShort(this.toShort())
|
||||
public fun Short.toUShort(): UShort = UShort(this.toShort())
|
||||
public fun Byte.toUShort(): UShort = UShort(this.toShort() and 0xFF)
|
||||
public fun Short.toUShort(): UShort = UShort(this)
|
||||
public fun Int.toUShort(): UShort = UShort(this.toShort())
|
||||
public fun Long.toUShort(): UShort = UShort(this.toShort())
|
||||
|
||||
Reference in New Issue
Block a user