Skip to content

Commit f15009c

Browse files
committed
- experimental inv()
1 parent 5928b52 commit f15009c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/kotlin/unsigned/unsigned.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package unsigned
22

33
import java.math.BigInteger
44
import kotlin.experimental.and
5+
import kotlin.experimental.inv
56
import kotlin.experimental.or
67
import kotlin.experimental.xor
78

@@ -106,7 +107,7 @@ data class Ubyte(var v: Byte = 0) : Number() {
106107
infix fun shr(b: Byte) = Ubyte(toInt() ushr b.toUInt())
107108
infix fun shr(b: Int) = Ubyte(toInt() ushr b)
108109

109-
fun inv() = Ubyte(toInt().inv())
110+
fun inv() = Ubyte(v.inv())
110111

111112
operator fun compareTo(b: Ubyte) = Integer.compareUnsigned(toInt(), b.toInt())
112113
operator fun compareTo(b: Byte) = Integer.compareUnsigned(toInt(), b.toUInt())
@@ -352,7 +353,7 @@ data class Ushort(var v: Short = 0) : Number() {
352353
infix fun shr(b: Short) = Ushort(toInt() ushr b.toUInt())
353354
infix fun shr(b: Int) = Ushort(toInt() ushr b)
354355

355-
fun inv() = Ushort(toInt().inv())
356+
fun inv() = Ushort(v.inv())
356357

357358
operator fun compareTo(b: Ushort) = Integer.compareUnsigned(toInt(), b.toInt())
358359
operator fun compareTo(b: Short) = Integer.compareUnsigned(toInt(), b.toUInt())

0 commit comments

Comments
 (0)