@@ -8,13 +8,15 @@ import java.math.BigInteger
8
8
fun Long.toUByte () = toByte()
9
9
fun Long.toUShort () = toShort()
10
10
fun Long.toUInt () = toInt()
11
- fun Long.toBigInt () = BigInteger (java.lang.Long .toUnsignedString(this ))
12
11
13
12
fun Long.toUbyte () = Ubyte (this )
14
13
fun Long.toUshort () = Ushort (this )
15
14
fun Long.toUint () = Uint (this )
16
15
fun Long.toUlong () = Ulong (this )
17
16
17
+ fun Long.toBigInt (): BigInteger = BigInteger .valueOf(this )
18
+ fun Long.toUBigInt (): BigInteger = BigInteger (java.lang.Long .toUnsignedString(this ))
19
+
18
20
val Long .ub
19
21
get() = toUbyte()
20
22
val Long .ui
@@ -24,24 +26,24 @@ val Long.ul
24
26
val Long .us
25
27
get() = toUshort()
26
28
27
- infix fun Long.udiv (b : Byte ) = (toBigInt () / b.toBigInt ()).toLong()
28
- infix fun Long.urem (b : Byte ) = (toBigInt () % b.toBigInt ()).toLong()
29
- infix fun Long.ucmp (b : Byte ) = toBigInt ().compareTo(b.toBigInt ())
30
- infix fun Long.ushr (b : Byte ) = (toBigInt () ushr b.toUInt()).toLong()
29
+ infix fun Long.udiv (b : Byte ) = (toUBigInt () / b.toUBigInt ()).toLong()
30
+ infix fun Long.urem (b : Byte ) = (toUBigInt () % b.toUBigInt ()).toLong()
31
+ infix fun Long.ucmp (b : Byte ) = toUBigInt ().compareTo(b.toUBigInt ())
32
+ infix fun Long.ushr (b : Byte ) = (toUBigInt () ushr b.toUInt()).toLong()
31
33
32
- infix fun Long.udiv (b : Short ) = (toBigInt () / b.toBigInt ()).toLong()
33
- infix fun Long.urem (b : Short ) = (toBigInt () % b.toBigInt ()).toLong()
34
- infix fun Long.ucmp (b : Short ) = toBigInt ().compareTo(b.toBigInt ())
35
- infix fun Long.ushr (b : Short ) = (toBigInt () ushr b.toUInt()).toLong()
34
+ infix fun Long.udiv (b : Short ) = (toUBigInt () / b.toUBigInt ()).toLong()
35
+ infix fun Long.urem (b : Short ) = (toUBigInt () % b.toUBigInt ()).toLong()
36
+ infix fun Long.ucmp (b : Short ) = toUBigInt ().compareTo(b.toUBigInt ())
37
+ infix fun Long.ushr (b : Short ) = (toUBigInt () ushr b.toUInt()).toLong()
36
38
37
- infix fun Long.udiv (b : Int ) = (toBigInt () / b.toBigInt ()).toLong()
38
- infix fun Long.urem (b : Int ) = (toBigInt () % b.toBigInt ()).toLong()
39
- infix fun Long.ucmp (b : Int ) = toBigInt ().compareTo(b.toBigInt ())
39
+ infix fun Long.udiv (b : Int ) = (toUBigInt () / b.toUBigInt ()).toLong()
40
+ infix fun Long.urem (b : Int ) = (toUBigInt () % b.toUBigInt ()).toLong()
41
+ infix fun Long.ucmp (b : Int ) = toUBigInt ().compareTo(b.toUBigInt ())
40
42
// Long.ushr(b: Int) offered by Kotlin lib
41
43
42
- infix fun Long.udiv (b : Long ) = (toBigInt () / b.toBigInt ()).toLong()
43
- infix fun Long.urem (b : Long ) = (toBigInt () % b.toBigInt ()).toLong()
44
- infix fun Long.ucmp (b : Long ) = toBigInt ().compareTo(b.toBigInt ())
44
+ infix fun Long.udiv (b : Long ) = (toUBigInt () / b.toUBigInt ()).toLong()
45
+ infix fun Long.urem (b : Long ) = (toUBigInt () % b.toUBigInt ()).toLong()
46
+ infix fun Long.ucmp (b : Long ) = toUBigInt ().compareTo(b.toUBigInt ())
45
47
// no Long ushr Long
46
48
47
49
@@ -53,9 +55,9 @@ infix fun Long.or(b: Ubyte) = this or b.toLong()
53
55
infix fun Long.xor (b : Ubyte ) = this xor b.toLong()
54
56
infix fun Long.shl (b : Ubyte ) = this shl b.toInt()
55
57
56
- infix fun Long.udiv (b : Ubyte ) = (toBigInt () / b.toBigInt()).toLong()
57
- infix fun Long.urem (b : Ubyte ) = (toBigInt () % b.toBigInt()).toLong()
58
- infix fun Long.ucmp (b : Ubyte ) = toBigInt ().compareTo(b.toBigInt())
58
+ infix fun Long.udiv (b : Ubyte ) = (toUBigInt () / b.toBigInt()).toLong()
59
+ infix fun Long.urem (b : Ubyte ) = (toUBigInt () % b.toBigInt()).toLong()
60
+ infix fun Long.ucmp (b : Ubyte ) = toUBigInt ().compareTo(b.toBigInt())
59
61
infix fun Long.ushr (b : Ubyte ) = this ushr b.toInt()
60
62
61
63
@@ -67,10 +69,10 @@ infix fun Long.or(b: Ushort) = this or b.toLong()
67
69
infix fun Long.xor (b : Ushort ) = this xor b.toLong()
68
70
infix fun Long.shl (b : Ushort ) = this shl b.toInt()
69
71
70
- infix fun Long.udiv (b : Ushort ) = (toBigInt () / b.toBigInt()).toLong()
71
- infix fun Long.urem (b : Ushort ) = (toBigInt () % b.toBigInt()).toLong()
72
- infix fun Long.ucmp (b : Ushort ) = toBigInt ().compareTo(b.toBigInt())
73
- infix fun Long.ushr (b : Ushort ) = (toBigInt () ushr b.toInt()).toLong()
72
+ infix fun Long.udiv (b : Ushort ) = (toUBigInt () / b.toBigInt()).toLong()
73
+ infix fun Long.urem (b : Ushort ) = (toUBigInt () % b.toBigInt()).toLong()
74
+ infix fun Long.ucmp (b : Ushort ) = toUBigInt ().compareTo(b.toBigInt())
75
+ infix fun Long.ushr (b : Ushort ) = (toUBigInt () ushr b.toInt()).toLong()
74
76
75
77
76
78
operator fun Long.plus (b : Uint ) = this + b.v
@@ -81,10 +83,10 @@ infix fun Long.or(b: Uint) = this or b.toLong()
81
83
infix fun Long.xor (b : Uint ) = this xor b.toLong()
82
84
infix fun Long.shl (b : Uint ) = this shl b.v
83
85
84
- infix fun Long.udiv (b : Uint ) = (toBigInt () / b.toBigInt()).toLong()
85
- infix fun Long.urem (b : Uint ) = (toBigInt () % b.toBigInt()).toLong()
86
- infix fun Long.ucmp (b : Uint ) = toBigInt ().compareTo(b.toBigInt())
87
- infix fun Long.ushr (b : Uint ) = (toBigInt () ushr b.toInt()).toLong()
86
+ infix fun Long.udiv (b : Uint ) = (toUBigInt () / b.toBigInt()).toLong()
87
+ infix fun Long.urem (b : Uint ) = (toUBigInt () % b.toBigInt()).toLong()
88
+ infix fun Long.ucmp (b : Uint ) = toUBigInt ().compareTo(b.toBigInt())
89
+ infix fun Long.ushr (b : Uint ) = (toUBigInt () ushr b.toInt()).toLong()
88
90
89
91
90
92
operator fun Long.plus (b : Ulong ) = this + b.v
@@ -95,7 +97,7 @@ infix fun Long.or(b: Ulong) = this or b.toLong()
95
97
infix fun Long.xor (b : Ulong ) = this xor b.toLong()
96
98
infix fun Long.shl (b : Ulong ) = this shl b.toInt()
97
99
98
- infix fun Long.udiv (b : Ulong ) = (toBigInt () / b.toBigInt()).toLong()
99
- infix fun Long.urem (b : Ulong ) = (toBigInt () % b.toBigInt()).toLong()
100
- infix fun Long.ucmp (b : Ulong ) = toBigInt ().compareTo(b.toBigInt())
100
+ infix fun Long.udiv (b : Ulong ) = (toUBigInt () / b.toBigInt()).toLong()
101
+ infix fun Long.urem (b : Ulong ) = (toUBigInt () % b.toBigInt()).toLong()
102
+ infix fun Long.ucmp (b : Ulong ) = toUBigInt ().compareTo(b.toBigInt())
101
103
// no Int ushr Ulong
0 commit comments