-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInt64Math.hx
226 lines (175 loc) · 5.74 KB
/
Int64Math.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
package deep.math;
import haxe.Int32;
import haxe.Int64;
/**
* ...
* @author deep <system.grand@gmail.com>
*/
class Int64Math
{
@op("+", true) inline static public var add = Int64.add;
@op("+", true) inline static public function addInt32(a:Int64, b:Int32):Int64
{
return Int64.add(a, Int64.ofInt32(b));
}
@op("+", true) inline static public function addInt(a:Int64, b:Int):Int64
{
return Int64.add(a, Int64.ofInt(b));
}
@op("-", true) inline static public var sub = Int64.sub;
@op("-", false) inline static public function subInt32(a:Int64, b:Int32):Int64
{
return Int64.sub(a, Int64.ofInt32(b));
}
@op("-", false) inline static public function subInt(a:Int64, b:Int):Int64
{
return Int64.sub(a, Int64.ofInt(b));
}
@op("*", true) inline static public var mult = Int64.mul;
@op("*", true) inline static public function multInt32(a:Int64, b:Int32):Int64
{
return Int64.mul(a, Int64.ofInt32(b));
}
@op("*", true) inline static public function multInt(a:Int64, b:Int):Int64
{
return Int64.mul(a, Int64.ofInt(b));
}
@op("/", true) inline static public var div = Int64.div;
@op("/", false) inline static public function divInt32(a:Int64, b:Int32):Int64
{
return Int64.div(a, Int64.ofInt32(b));
}
@op("/", false) inline static public function divInt(a:Int64, b:Int):Int64
{
return Int64.div(a, Int64.ofInt(b));
}
@op("%", true) inline static public var mod = Int64.mod;
@op("%", false) inline static public function modInt32(a:Int64, b:Int32):Int64
{
return Int64.mod(a, Int64.ofInt32(b));
}
@op("%", false) inline static public function modInt(a:Int64, b:Int):Int64
{
return Int64.mod(a, Int64.ofInt(b));
}
@op("+=", true) inline static public var iadd = Int64.add;
@op("+=", false) inline static public function iaddInt32(a:Int64, b:Int32):Int64
{
return Int64.add(a, Int64.ofInt32(b));
}
@op("+=", false) inline static public function iaddInt(a:Int64, b:Int):Int64
{
return Int64.add(a, Int64.ofInt(b));
}
@op("-=", true) inline static public var isub = Int64.sub;
@op("-=", false) inline static public function isubInt32(a:Int64, b:Int32):Int64
{
return Int64.sub(a, Int64.ofInt32(b));
}
@op("-=", false) inline static public function isubInt(a:Int64, b:Int):Int64
{
return Int64.sub(a, Int64.ofInt(b));
}
@op("*=", true) inline static public var imult = Int64.mul;
@op("*=", false) inline static public function imultInt32(a:Int64, b:Int32):Int64
{
return Int64.mul(a, Int64.ofInt32(b));
}
@op("*=", false) inline static public function imultInt(a:Int64, b:Int):Int64
{
return Int64.mul(a, Int64.ofInt(b));
}
@op("/=", true) inline static public var idiv = Int64.div;
@op("/=", false) inline static public function idivInt32(a:Int64, b:Int32):Int64
{
return Int64.div(a, Int64.ofInt32(b));
}
@op("/=", false) inline static public function idivInt(a:Int64, b:Int):Int64
{
return Int64.div(a, Int64.ofInt(b));
}
@op("%=", true) inline static public var imod = Int64.mod;
@op("%=", false) inline static public function imodInt32(a:Int64, b:Int32):Int64
{
return Int64.mod(a, Int64.ofInt32(b));
}
@op("%=", false) inline static public function imodInt(a:Int64, b:Int):Int64
{
return Int64.mod(a, Int64.ofInt(b));
}
@op("<<", true) inline static public var shl = Int64.shl;
@op("<<=", true) inline static public var ishl = Int64.shl;
@op(">>", true) inline static public var shr = Int64.shr;
@op(">>=", true) inline static public var ishr = Int64.shr;
@op(">>>", true) inline static public var ushr = Int64.ushr;
@op(">>>=", true) inline static public var iushr = Int64.ushr;
@op("&", true) inline static public var and = Int64.and;
@op("&=", true) inline static public var iand = Int64.and;
@op("|", true) inline static public var or = Int64.or;
@op("|=", true) inline static public var ior = Int64.or;
@op("^", true) inline static public var xor = Int64.xor;
@op("^=", true) inline static public var ixor = Int64.xor;
@op("-x") inline static public var neg = Int64.neg;
@op("++x", false) inline static public function inc(a:Int64):Int64
{
return Int64.add(a, Int64.ofInt(1));
}
@op("x++", false) inline static public function pinc(a:Int64):Int64
{
return Int64.add(a, Int64.ofInt(1));
}
@op("--x", false) inline static public function dec(a:Int64):Int64
{
return Int64.sub(a, Int64.ofInt(1));
}
@op("x--", false) inline static public function pdec(a:Int64):Int64
{
return Int64.sub(a, Int64.ofInt(1));
}
@op(">", false) inline static public function gt(a:Int64, b:Int64):Bool
{
return Int64.compare(a, b) > 0;
}
@op(">=", false) inline static public function gte(a:Int64, b:Int64):Bool
{
return Int64.compare(a, b) >= 0;
}
@op("<", false) inline static public function lt(a:Int64, b:Int64):Bool
{
return Int64.compare(a, b) < 0;
}
@op("<=", false) inline static public function lte(a:Int64, b:Int64):Bool
{
return Int64.compare(a, b) <= 0;
}
@op("==", true) inline static public function eq(a:Int64, b:Int64):Bool
{
return Int64.compare(a, b) == 0;
}
@op("==", true) inline public static function eqInt32(a:Int64, b:Int32):Bool
{
return Int64.compare(a, Int64.ofInt32(b)) == 0;
}
@op("==", true) inline public static function eqInt(a:Int64, b:Int):Bool
{
return Int64.compare(a, Int64.ofInt(b)) == 0;
}
@op("!=", true) inline static public function neq(a:Int64, b:Int64):Bool
{
return Int64.compare(a, b) != 0;
}
@op("!=", true) inline public static function neqInt32(a:Int64, b:Int32):Bool
{
return Int64.compare(a, Int64.ofInt32(b)) != 0;
}
@op("!=", true) inline public static function neqInt(a:Int64, b:Int):Bool
{
return Int64.compare(a, Int64.ofInt(b)) != 0;
}
inline static public function abs(a:Int64):Int64
{
if (Int64.isNeg(a))
return Int64.neg(a);
return a;
}
}