1- package unsigned
2-
3- import unsigned.toUInt
4-
51/* *
62 * Created by elect on 19/01/2017.
73 */
84
9- infix fun Byte. udiv ( b : Byte ) = (toUInt() / b.toUInt()).toByte()
5+ package unsigned
106
11- infix fun Byte.urem (b : Byte ) = (toUInt() % b.toUInt()).toByte()
12- infix fun Byte.ucmp (b : Byte ) = toUInt().compareTo(b.toUInt())
13- infix fun Byte.ushr (b : Byte ) = (toUInt() ushr b.toUInt()).toByte()
7+ import toBigInt
8+ import java.math.BigInteger
9+ import kotlin.experimental.and
10+ import kotlin.experimental.or
11+ import kotlin.experimental.xor
1412
15- infix fun Byte.udiv (b : Int ) = (toUInt() / b).toByte()
16- infix fun Byte.urem (b : Int ) = (toUInt() % b).toByte()
17- infix fun Byte.ucmp (b : Int ) = toUInt().compareTo(b)
18- infix fun Byte.ushr (b : Int ) = (toUInt() ushr b).toByte()
13+
14+ fun Byte.toUShort () = toUInt().toShort()
15+ fun Byte.toUInt () = toInt() and 0xff
16+ fun Byte.toULong () = toUInt().toLong()
17+ fun Byte.toBigInt () = BigInteger .valueOf(toULong())
1918
2019fun Byte.toUbyte () = Ubyte (this )
20+ fun Byte.toUshort () = Ushort (toUInt())
2121fun Byte.toUint () = Uint (toUInt())
2222fun Byte.toUlong () = Ulong (toUInt())
23- fun Byte.toUshort () = Ushort (toUInt())
2423
2524val Byte .ub
2625 get() = toUbyte()
@@ -29,4 +28,81 @@ val Byte.ui
2928val Byte .ul
3029 get() = toUlong()
3130val Byte .us
32- get() = toUshort()
31+ get() = toUshort()
32+
33+ infix fun Byte.udiv (b : Byte ) = (toUInt() / b.toUInt()).toByte()
34+ infix fun Byte.urem (b : Byte ) = (toUInt() % b.toUInt()).toByte()
35+ infix fun Byte.ucmp (b : Byte ) = toUInt().compareTo(b.toUInt())
36+ infix fun Byte.ushr (b : Byte ) = (toUInt() ushr b.toUInt()).toByte()
37+
38+ infix fun Byte.udiv (b : Short ) = (toUInt() / b.toUInt()).toByte()
39+ infix fun Byte.urem (b : Short ) = (toUInt() % b.toUInt()).toByte()
40+ infix fun Byte.ucmp (b : Short ) = toUInt().compareTo(b.toUInt())
41+ infix fun Byte.ushr (b : Short ) = (toUInt() ushr b.toUInt()).toByte()
42+
43+ infix fun Byte.udiv (b : Int ) = (toULong() / b.toULong()).toByte()
44+ infix fun Byte.urem (b : Int ) = (toULong() % b.toULong()).toByte()
45+ infix fun Byte.ucmp (b : Int ) = toULong().compareTo(b.toULong())
46+ infix fun Byte.ushr (b : Int ) = (toUInt() ushr b).toByte()
47+
48+ infix fun Byte.udiv (b : Long ) = (toBigInt() / b.toBigInt()).toByte()
49+ infix fun Byte.urem (b : Long ) = (toBigInt() % b.toBigInt()).toByte()
50+ infix fun Byte.ucmp (b : Long ) = toBigInt().compareTo(b.toBigInt())
51+ // no Byte ushr Long
52+
53+
54+ operator fun Byte.plus (b : Ubyte ) = (this + b.v).toByte()
55+ operator fun Byte.minus (b : Ubyte ) = (this - b.v).toByte()
56+ operator fun Byte.times (b : Ubyte ) = (this * b.v).toByte()
57+ infix fun Byte.and (b : Ubyte ) = this and b.v
58+ infix fun Byte.or (b : Ubyte ) = this or b.v
59+ infix fun Byte.xor (b : Ubyte ) = this xor b.v
60+ infix fun Byte.shl (b : Ubyte ) = (toInt() shl b.toInt()).toByte()
61+
62+ infix fun Byte.udiv (b : Ubyte ) = (toUInt() / b.toInt()).toByte()
63+ infix fun Byte.urem (b : Ubyte ) = (toUInt() % b.toInt()).toByte()
64+ infix fun Byte.ucmp (b : Ubyte ) = toUInt().compareTo(b.toInt())
65+ infix fun Byte.ushr (b : Ubyte ) = (toUInt() ushr b.toInt()).toByte()
66+
67+
68+ operator fun Byte.plus (b : Ushort ) = (this + b.v).toByte()
69+ operator fun Byte.minus (b : Ushort ) = (this - b.v).toByte()
70+ operator fun Byte.times (b : Ushort ) = (this * b.v).toByte()
71+ infix fun Byte.and (b : Ushort ) = this and b.toByte()
72+ infix fun Byte.or (b : Ushort ) = this or b.toByte()
73+ infix fun Byte.xor (b : Ushort ) = this xor b.toByte()
74+ infix fun Byte.shl (b : Ushort ) = (toInt() shl b.toInt()).toByte()
75+
76+ infix fun Byte.udiv (b : Ushort ) = (toUInt() / b.toInt()).toByte()
77+ infix fun Byte.urem (b : Ushort ) = (toUInt() % b.toInt()).toByte()
78+ infix fun Byte.ucmp (b : Ushort ) = toUInt().compareTo(b.toInt())
79+ infix fun Byte.ushr (b : Ushort ) = (toUInt() ushr b.toInt()).toByte()
80+
81+
82+ operator fun Byte.plus (b : Uint ) = (this + b.v).toByte()
83+ operator fun Byte.minus (b : Uint ) = (this - b.v).toByte()
84+ operator fun Byte.times (b : Uint ) = (this * b.v).toByte()
85+ infix fun Byte.and (b : Uint ) = this and b.toByte()
86+ infix fun Byte.or (b : Uint ) = this or b.toByte()
87+ infix fun Byte.xor (b : Uint ) = this xor b.toByte()
88+ infix fun Byte.shl (b : Uint ) = (toInt() shl b.v).toByte()
89+
90+ infix fun Byte.udiv (b : Uint ) = (toULong() / b.toLong()).toByte()
91+ infix fun Byte.urem (b : Uint ) = (toULong() % b.toLong()).toByte()
92+ infix fun Byte.ucmp (b : Uint ) = toULong().compareTo(b.toLong())
93+ infix fun Byte.ushr (b : Uint ) = (toUInt() ushr b.toInt()).toByte()
94+
95+
96+ operator fun Byte.plus (b : Ulong ) = (this + b.v).toByte()
97+ operator fun Byte.minus (b : Ulong ) = (this - b.v).toByte()
98+ operator fun Byte.times (b : Ulong ) = (this * b.v).toByte()
99+ infix fun Byte.and (b : Ulong ) = this and b.toByte()
100+ infix fun Byte.or (b : Ulong ) = this or b.toByte()
101+ infix fun Byte.xor (b : Ulong ) = this xor b.toByte()
102+ infix fun Byte.shl (b : Ulong ) = (toInt() shl b.toInt()).toByte()
103+
104+ infix fun Byte.udiv (b : Ulong ) = (toULong() / b.toLong()).toByte()
105+ infix fun Byte.urem (b : Ulong ) = (toULong() % b.toLong()).toByte()
106+ infix fun Byte.ucmp (b : Ulong ) = toULong().compareTo(b.toLong())
107+ // no Byte ushr Ulong
108+
0 commit comments