1+ package unsigned
2+
13import java.math.BigInteger
24
35/* *
@@ -34,7 +36,7 @@ infix fun Long.urem(b: Long) = java.lang.Long.remainderUnsigned(this, b)
3436infix fun Long.ucmp (b : Long ) = java.lang.Long .compareUnsigned(this , b)
3537// Long.ushl(b: Long) is already provided by Kotlin lib
3638
37- // TODO if == Ubyte?
39+ // TODO if == unsigned. Ubyte?
3840fun Number.toUbyte () = Ubyte (toByte())
3941fun Number.toUint () = Uint (this )
4042fun Number.toUlong () = Ulong (toLong())
@@ -407,7 +409,7 @@ infix fun Int.or(b: Ubyte) = this or b.toInt()
407409infix fun Int.xor (b : Ubyte ) = this xor b.toInt()
408410infix fun Int.shl (b : Ubyte ) = this shl b.toInt()
409411infix fun Int.shr (b : Ubyte ) = this shr b.toInt()
410- // Int.inv() is already provided by Kotlin lib
412+ // Int.unsigned. inv() is already provided by Kotlin lib
411413infix operator fun Int.compareTo (b : Ubyte ) = Integer .compareUnsigned(this , b.toInt())
412414
413415
@@ -421,7 +423,7 @@ infix fun Int.or(b: Uint) = this or b.toInt()
421423infix fun Int.xor (b : Uint ) = this xor b.toInt()
422424infix fun Int.shl (b : Uint ) = this shl b.toInt()
423425infix fun Int.shr (b : Uint ) = this shr b.toInt()
424- // Int.inv() is already provided by Kotlin lib
426+ // Int.unsigned. inv() is already provided by Kotlin lib
425427infix operator fun Int.compareTo (b : Uint ) = Integer .compareUnsigned(this , b.toInt())
426428
427429
@@ -433,7 +435,7 @@ operator fun Long.rem(b: Ulong) = java.lang.Long.remainderUnsigned(this, b.toLon
433435infix fun Long.and (b : Ulong ) = this and b.toLong()
434436infix fun Long.or (b : Ulong ) = this or b.toLong()
435437infix fun Long.xor (b : Ulong ) = this xor b.toLong()
436- // no main.shl, main.shr, since they need int
438+ // no main.unsigned. shl, main.unsigned .shr, since they need int
437439infix operator fun Long.compareTo (b : Ulong ) = java.lang.Long .compareUnsigned(this , b.toLong())
438440
439441
@@ -461,5 +463,5 @@ infix fun Int.or(b: Ushort) = this or b.toInt()
461463infix fun Int.xor (b : Ushort ) = this xor b.toInt()
462464infix fun Int.shl (b : Ushort ) = this shl b.toInt()
463465infix fun Int.shr (b : Ushort ) = this shr b.toInt()
464- // Int.inv() is already provided by Kotlin lib
466+ // Int.unsigned. inv() is already provided by Kotlin lib
465467infix operator fun Int.compareTo (b : Ushort ) = Integer .compareUnsigned(this , b.toInt())
0 commit comments