Change signed to unsigned widening conversions to sign-extending

e.g. `Byte.toUInt()` now returns `UInt.MAX_VALUE` for Byte value of -1 instead of 0xFFu.

#KT-26594 Fixed
This commit is contained in:
Ilya Gorbunov
2018-09-05 06:26:12 +03:00
parent 4344005fb5
commit 82d35cfa26
5 changed files with 17 additions and 14 deletions
@@ -132,9 +132,9 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
public fun toLong(): Long = data.toLong() and 0xFF
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 toUShort(): UShort = data.toUShort() and 0xFFu
public fun toUInt(): UInt = data.toUInt() and 0xFFu
public fun toULong(): ULong = data.toULong() and 0xFFu
public override fun toString(): String = toInt().toString()