Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 796 lines (618 sloc) 20.799 kB
8bdb1e5 @substack hooray it works!
authored
1 #include <stdint.h>
2 #include <cstdio>
3 #include <cstdlib>
4 #include <cstring>
c234211 @draggor Changing from FFI to c++ node module
draggor authored
5 #include <iostream>
8bdb1e5 @substack hooray it works!
authored
6
c234211 @draggor Changing from FFI to c++ node module
draggor authored
7 #include <v8.h>
8 #include <node.h>
8bdb1e5 @substack hooray it works!
authored
9 #include <gmp.h>
10 #include <map>
11 #include <utility>
12
c234211 @draggor Changing from FFI to c++ node module
draggor authored
13 using namespace v8;
14 using namespace node;
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
15 using namespace std;
16
17 #define REQ_STR_ARG(I, VAR) \
18 if (args.Length()<= (I) || !args[I]->IsString()) \
19 return ThrowException(Exception::TypeError( \
20 String::New("Argument " #I " must be a string"))); \
21 Local<String> VAR = Local<String>::Cast(args[I]);
22
23 #define REQ_UTF8_ARG(I, VAR) \
24 if (args.Length() <= (I) || !args[I]->IsString()) \
25 return ThrowException(Exception::TypeError( \
26 String::New("Argument " #I " must be a utf8 string"))); \
27 String::Utf8Value VAR(args[I]->ToString());
28
29 #define REQ_INT32_ARG(I, VAR) \
30 if (args.Length() <= (I) || !args[I]->IsInt32()) \
31 return ThrowException(Exception::TypeError( \
32 String::New("Argument " #I " must be an int32"))); \
33 int32_t VAR = args[I]->ToInt32()->Value();
34
35 #define REQ_UINT32_ARG(I, VAR) \
36 if (args.Length() <= (I) || !args[I]->IsUint32()) \
37 return ThrowException(Exception::TypeError( \
38 String::New("Argument " #I " must be a uint32"))); \
39 uint32_t VAR = args[I]->ToUint32()->Value();
40
41 #define REQ_INT64_ARG(I, VAR) \
42 if (args.Length() <= (I) || !args[I]->IsNumber()) \
43 return ThrowException(Exception::TypeError( \
44 String::New("Argument " #I " must be an int64"))); \
45 int64_t VAR = args[I]->ToInteger()->Value();
46
47 #define REQ_UINT64_ARG(I, VAR) \
48 if (args.Length() <= (I) || !args[I]->IsNumber()) \
49 return ThrowException(Exception::TypeError( \
50 String::New("Argument " #I " must be a uint64"))); \
51 uint64_t VAR = args[I]->ToInteger()->Value();
52
53 #define WRAP_RESULT(RES, VAR) \
54 Handle<Value> arg[1] = { External::New(*RES) }; \
55 Local<Object> VAR = constructor_template->GetFunction()->NewInstance(1, arg);
56
57 class BigInt : ObjectWrap {
58 public:
59 static void Initialize(Handle<Object> target);
60 mpz_t *bigint_;
61 static Persistent<Function> js_conditioner;
62 static void SetJSConditioner(Persistent<Function> constructor);
63
64 protected:
65 static Persistent<FunctionTemplate> constructor_template;
66
67 BigInt(const String::Utf8Value& str, uint64_t base);
68 BigInt(uint64_t num);
69 BigInt(int64_t num);
70 BigInt(mpz_t *num);
71 BigInt();
72 ~BigInt();
73
74 static Handle<Value> New(const Arguments& args);
75 static Handle<Value> ToString(const Arguments& args);
76 static Handle<Value> Badd(const Arguments& args);
77 static Handle<Value> Bsub(const Arguments& args);
78 static Handle<Value> Bmul(const Arguments& args);
79 static Handle<Value> Bdiv(const Arguments& args);
80 static Handle<Value> Uadd(const Arguments& args);
81 static Handle<Value> Usub(const Arguments& args);
82 static Handle<Value> Umul(const Arguments& args);
83 static Handle<Value> Udiv(const Arguments& args);
7bcc87e @justmoon Added support for bitwise shift operation.
justmoon authored
84 static Handle<Value> Umul_2exp(const Arguments& args);
85 static Handle<Value> Udiv_2exp(const Arguments& args);
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
86 static Handle<Value> Babs(const Arguments& args);
87 static Handle<Value> Bneg(const Arguments& args);
88 static Handle<Value> Bmod(const Arguments& args);
89 static Handle<Value> Umod(const Arguments& args);
90 static Handle<Value> Bpowm(const Arguments& args);
91 static Handle<Value> Upowm(const Arguments& args);
92 static Handle<Value> Upow(const Arguments& args);
93 static Handle<Value> Uupow(const Arguments& args);
94 static Handle<Value> Brand0(const Arguments& args);
95 static Handle<Value> Probprime(const Arguments& args);
96 static Handle<Value> Nextprime(const Arguments& args);
97 static Handle<Value> Bcompare(const Arguments& args);
98 static Handle<Value> Scompare(const Arguments& args);
99 static Handle<Value> Ucompare(const Arguments& args);
100 static Handle<Value> Band(const Arguments& args);
101 static Handle<Value> Bor(const Arguments& args);
102 static Handle<Value> Bxor(const Arguments& args);
103 static Handle<Value> Binvertm(const Arguments& args);
104 static Handle<Value> Bsqrt(const Arguments& args);
105 static Handle<Value> Broot(const Arguments& args);
88e5265 @benadida added bitLength method
benadida authored
106 static Handle<Value> BitLength(const Arguments& args);
2ac68fb @benadida added gcd method
benadida authored
107 static Handle<Value> Bgcd(const Arguments& args);
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
108 };
109
110 static gmp_randstate_t * randstate = NULL;
111
112 Persistent<FunctionTemplate> BigInt::constructor_template;
113
114 Persistent<Function> BigInt::js_conditioner;
115
116 void BigInt::SetJSConditioner(Persistent<Function> constructor) {
117 js_conditioner = constructor;
118 }
119
120 void BigInt::Initialize(v8::Handle<v8::Object> target) {
121 HandleScope scope;
122
123 Local<FunctionTemplate> t = FunctionTemplate::New(New);
124 constructor_template = Persistent<FunctionTemplate>::New(t);
125
126 constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
127 constructor_template->SetClassName(String::NewSymbol("BigInt"));
128
129 NODE_SET_PROTOTYPE_METHOD(constructor_template, "toString", ToString);
130 NODE_SET_PROTOTYPE_METHOD(constructor_template, "badd", Badd);
131 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bsub", Bsub);
132 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bmul", Bmul);
133 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bdiv", Bdiv);
134 NODE_SET_PROTOTYPE_METHOD(constructor_template, "uadd", Uadd);
135 NODE_SET_PROTOTYPE_METHOD(constructor_template, "usub", Usub);
136 NODE_SET_PROTOTYPE_METHOD(constructor_template, "umul", Umul);
137 NODE_SET_PROTOTYPE_METHOD(constructor_template, "udiv", Udiv);
7bcc87e @justmoon Added support for bitwise shift operation.
justmoon authored
138 NODE_SET_PROTOTYPE_METHOD(constructor_template, "umul2exp", Umul_2exp);
139 NODE_SET_PROTOTYPE_METHOD(constructor_template, "udiv2exp", Udiv_2exp);
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
140 NODE_SET_PROTOTYPE_METHOD(constructor_template, "babs", Babs);
141 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bneg", Bneg);
142 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bmod", Bmod);
143 NODE_SET_PROTOTYPE_METHOD(constructor_template, "umod", Umod);
144 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bpowm", Bpowm);
145 NODE_SET_PROTOTYPE_METHOD(constructor_template, "upowm", Upowm);
146 NODE_SET_PROTOTYPE_METHOD(constructor_template, "upow", Upow);
147 NODE_SET_PROTOTYPE_METHOD(constructor_template, "uupow", Uupow);
148 NODE_SET_PROTOTYPE_METHOD(constructor_template, "brand0", Brand0);
149 NODE_SET_PROTOTYPE_METHOD(constructor_template, "probprime", Probprime);
150 NODE_SET_PROTOTYPE_METHOD(constructor_template, "nextprime", Nextprime);
151 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bcompare", Bcompare);
152 NODE_SET_PROTOTYPE_METHOD(constructor_template, "scompare", Scompare);
153 NODE_SET_PROTOTYPE_METHOD(constructor_template, "ucompare", Ucompare);
154 NODE_SET_PROTOTYPE_METHOD(constructor_template, "band", Band);
155 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bor", Bor);
156 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bxor", Bxor);
157 NODE_SET_PROTOTYPE_METHOD(constructor_template, "binvertm", Binvertm);
158 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bsqrt", Bsqrt);
159 NODE_SET_PROTOTYPE_METHOD(constructor_template, "broot", Broot);
88e5265 @benadida added bitLength method
benadida authored
160 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bitLength", BitLength);
2ac68fb @benadida added gcd method
benadida authored
161 NODE_SET_PROTOTYPE_METHOD(constructor_template, "bgcd", Bgcd);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
162
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
163 target->Set(String::NewSymbol("BigInt"), constructor_template->GetFunction());
164 }
c234211 @draggor Changing from FFI to c++ node module
draggor authored
165
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
166 BigInt::BigInt (const v8::String::Utf8Value& str, uint64_t base) : ObjectWrap ()
c234211 @draggor Changing from FFI to c++ node module
draggor authored
167 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
168 bigint_ = (mpz_t *) malloc(sizeof(mpz_t));
169 mpz_init(*bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
170
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
171 mpz_set_str(*bigint_, *str, base);
172 }
c234211 @draggor Changing from FFI to c++ node module
draggor authored
173
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
174 BigInt::BigInt (uint64_t num) : ObjectWrap ()
175 {
176 bigint_ = (mpz_t *) malloc(sizeof(mpz_t));
177 mpz_init(*bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
178
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
179 mpz_set_ui(*bigint_, num);
180 }
c234211 @draggor Changing from FFI to c++ node module
draggor authored
181
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
182 BigInt::BigInt (int64_t num) : ObjectWrap ()
183 {
184 bigint_ = (mpz_t *) malloc(sizeof(mpz_t));
185 mpz_init(*bigint_);
186
187 mpz_set_si(*bigint_, num);
8bdb1e5 @substack hooray it works!
authored
188 }
189
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
190 BigInt::BigInt (mpz_t *num) : ObjectWrap ()
c234211 @draggor Changing from FFI to c++ node module
draggor authored
191 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
192 bigint_ = num;
193 }
c234211 @draggor Changing from FFI to c++ node module
draggor authored
194
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
195 BigInt::BigInt () : ObjectWrap ()
196 {
197 bigint_ = (mpz_t *) malloc(sizeof(mpz_t));
198 mpz_init(*bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
199
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
200 mpz_set_ui(*bigint_, 0);
8bdb1e5 @substack hooray it works!
authored
201 }
202
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
203 BigInt::~BigInt ()
c234211 @draggor Changing from FFI to c++ node module
draggor authored
204 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
205 mpz_clear(*bigint_);
206 free(bigint_);
207 }
208
209 Handle<Value>
210 BigInt::New(const Arguments& args)
211 {
212 if(!args.IsConstructCall()) {
b5cd783 @jb55 bigint.cc: Fixed compile errors for compilers complaining about varia…
jb55 authored
213 int len = args.Length();
214 Handle<Value>* newArgs = new Handle<Value>[len];
215 for(int i = 0; i < len; i++) {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
216 newArgs[i] = args[i];
217 }
b5cd783 @jb55 bigint.cc: Fixed compile errors for compilers complaining about varia…
jb55 authored
218 Handle<Value> newInst = constructor_template->GetFunction()->NewInstance(len, newArgs);
219 delete[] newArgs;
220 return newInst;
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
221 }
222 HandleScope scope;
223 BigInt *bigint;
224 uint64_t base;
225
226 if(args[0]->IsExternal()) {
227 mpz_t *num = (mpz_t *) External::Unwrap(args[0]);
228 bigint = new BigInt(num);
229 } else {
b5cd783 @jb55 bigint.cc: Fixed compile errors for compilers complaining about varia…
jb55 authored
230 int len = args.Length();
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
231 Local<Object> ctx = Local<Object>::New(Object::New());
b5cd783 @jb55 bigint.cc: Fixed compile errors for compilers complaining about varia…
jb55 authored
232 Handle<Value>* newArgs = new Handle<Value>[len];
233 for(int i = 0; i < len; i++) {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
234 newArgs[i] = args[i];
235 }
236 Local<Value> obj = js_conditioner->Call(ctx, args.Length(), newArgs);
237
2690309 @vadimg fix segfault when passing null or undefined to bigint constructor
vadimg authored
238 if(!*obj) {
239 return ThrowException(Exception::Error(String::New("Invalid type passed to bigint constructor")));
240 }
241
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
242 String::Utf8Value str(obj->ToObject()->Get(String::NewSymbol("num"))->ToString());
243 base = obj->ToObject()->Get(String::NewSymbol("base"))->ToNumber()->Value();
244
245 bigint = new BigInt(str, base);
b5cd783 @jb55 bigint.cc: Fixed compile errors for compilers complaining about varia…
jb55 authored
246 delete[] newArgs;
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
247 }
c234211 @draggor Changing from FFI to c++ node module
draggor authored
248
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
249 bigint->Wrap(args.This());
c234211 @draggor Changing from FFI to c++ node module
draggor authored
250
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
251 return scope.Close(args.This());
8bdb1e5 @substack hooray it works!
authored
252 }
253
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
254 Handle<Value>
255 BigInt::ToString(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
256 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
257 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
258 HandleScope scope;
259
260 uint64_t base = 10;
c234211 @draggor Changing from FFI to c++ node module
draggor authored
261
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
262 if(args.Length() > 0) {
263 REQ_UINT64_ARG(0, tbase);
b43bd9e @wfreeman Adding an error for toString instead of segfault if base is out of ra…
wfreeman authored
264 if(tbase < 2 || tbase > 62) {
265 return ThrowException(Exception::Error(String::New("Base should be between 2 and 62, inclusive")));
266 }
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
267 base = tbase;
268 }
269 char *to = mpz_get_str(0, base, *bigint->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
270
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
271 Handle<Value> result = String::New(to);
272 free(to);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
273
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
274 return scope.Close(result);
8bdb1e5 @substack hooray it works!
authored
275 }
b1617b3 @substack now does multiplication
authored
276
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
277 Handle<Value>
278 BigInt::Badd(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
279 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
280 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
281 HandleScope scope;
282
283 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
284 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
285 mpz_init(*res);
286
287 mpz_add(*res, *bigint->bigint_, *bi->bigint_);
d0f9505 @substack no tabs
authored
288
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
289 WRAP_RESULT(res, result);
290
291 return scope.Close(result);
09ef8ea @substack mysterious segfaults now
authored
292 }
293
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
294 Handle<Value>
295 BigInt::Bsub(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
296 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
297 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
298 HandleScope scope;
299
300 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
301 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
302 mpz_init(*res);
303 mpz_sub(*res, *bigint->bigint_, *bi->bigint_);
d0f9505 @substack no tabs
authored
304
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
305 WRAP_RESULT(res, result);
306
307 return scope.Close(result);
09ef8ea @substack mysterious segfaults now
authored
308 }
309
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
310 Handle<Value>
311 BigInt::Bmul(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
312 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
313 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
314 HandleScope scope;
315
316 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
317 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
318 mpz_init(*res);
319 mpz_mul(*res, *bigint->bigint_, *bi->bigint_);
320
321 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
322
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
323 return scope.Close(result);
b1617b3 @substack now does multiplication
authored
324 }
09ef8ea @substack mysterious segfaults now
authored
325
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
326 Handle<Value>
327 BigInt::Bdiv(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
328 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
329 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
330 HandleScope scope;
d0f9505 @substack no tabs
authored
331
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
332 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
333 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
334 mpz_init(*res);
335 mpz_div(*res, *bigint->bigint_, *bi->bigint_);
336
337 WRAP_RESULT(res, result);
338
339 return scope.Close(result);
09ef8ea @substack mysterious segfaults now
authored
340 }
3b246e8 @substack mpz_init() fixed the segfaults but there's an out of range thing now
authored
341
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
342 Handle<Value>
343 BigInt::Uadd(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
344 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
345 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
346 HandleScope scope;
347
348 REQ_UINT64_ARG(0, x);
349 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
350 mpz_init(*res);
351 mpz_add_ui(*res, *bigint->bigint_, x);
352
353 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
354
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
355 return scope.Close(result);
3b246e8 @substack mpz_init() fixed the segfaults but there's an out of range thing now
authored
356 }
357
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
358 Handle<Value>
359 BigInt::Usub(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
360 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
361 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
362 HandleScope scope;
363
364 REQ_UINT64_ARG(0, x);
365 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
366 mpz_init(*res);
367 mpz_sub_ui(*res, *bigint->bigint_, x);
368
369 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
370
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
371 return scope.Close(result);
3b246e8 @substack mpz_init() fixed the segfaults but there's an out of range thing now
authored
372 }
373
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
374 Handle<Value>
375 BigInt::Umul(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
376 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
377 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
378 HandleScope scope;
379
380 REQ_UINT64_ARG(0, x);
381 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
382 mpz_init(*res);
383 mpz_mul_ui(*res, *bigint->bigint_, x);
384
385 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
386
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
387 return scope.Close(result);
3b246e8 @substack mpz_init() fixed the segfaults but there's an out of range thing now
authored
388 }
389
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
390 Handle<Value>
391 BigInt::Udiv(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
392 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
393 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
394 HandleScope scope;
d0f9505 @substack no tabs
authored
395
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
396 REQ_UINT64_ARG(0, x);
397 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
398 mpz_init(*res);
399 mpz_div_ui(*res, *bigint->bigint_, x);
7bcc87e @justmoon Added support for bitwise shift operation.
justmoon authored
400
401 WRAP_RESULT(res, result);
402
403 return scope.Close(result);
404 }
405
406 Handle<Value>
407 BigInt::Umul_2exp(const Arguments& args)
408 {
409 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
410 HandleScope scope;
411
412 REQ_UINT64_ARG(0, x);
413 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
414 mpz_init(*res);
415 mpz_mul_2exp(*res, *bigint->bigint_, x);
416
417 WRAP_RESULT(res, result);
418
419 return scope.Close(result);
420 }
421
422 Handle<Value>
423 BigInt::Udiv_2exp(const Arguments& args)
424 {
425 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
426 HandleScope scope;
427
428 REQ_UINT64_ARG(0, x);
429 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
430 mpz_init(*res);
431 mpz_div_2exp(*res, *bigint->bigint_, x);
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
432
433 WRAP_RESULT(res, result);
434
435 return scope.Close(result);
3b246e8 @substack mpz_init() fixed the segfaults but there's an out of range thing now
authored
436 }
ca6b871 @substack abs and neg
authored
437
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
438 Handle<Value>
439 BigInt::Babs(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
440 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
441 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
442 HandleScope scope;
d0f9505 @substack no tabs
authored
443
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
444 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
445 mpz_init(*res);
446 mpz_abs(*res, *bigint->bigint_);
447
448 WRAP_RESULT(res, result);
449
450 return scope.Close(result);
ca6b871 @substack abs and neg
authored
451 }
452
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
453 Handle<Value>
454 BigInt::Bneg(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
455 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
456 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
457 HandleScope scope;
458
459 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
460 mpz_init(*res);
461 mpz_neg(*res, *bigint->bigint_);
462
463 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
464
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
465 return scope.Close(result);
ca6b871 @substack abs and neg
authored
466 }
e89bdf8 @substack untested power and modulo functions
authored
467
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
468 Handle<Value>
469 BigInt::Bmod(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
470 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
471 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
472 HandleScope scope;
473
474 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
475 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
476 mpz_init(*res);
477 mpz_mod(*res, *bigint->bigint_, *bi->bigint_);
478
479 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
480
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
481 return scope.Close(result);
e89bdf8 @substack untested power and modulo functions
authored
482 }
483
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
484 Handle<Value>
485 BigInt::Umod(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
486 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
487 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
488 HandleScope scope;
489
490 REQ_UINT64_ARG(0, x);
491 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
492 mpz_init(*res);
493 mpz_mod_ui(*res, *bigint->bigint_, x);
494
495 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
496
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
497 return scope.Close(result);
e89bdf8 @substack untested power and modulo functions
authored
498 }
499
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
500 Handle<Value>
501 BigInt::Bpowm(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
502 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
503 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
504 HandleScope scope;
d0f9505 @substack no tabs
authored
505
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
506 BigInt *bi1 = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
507 BigInt *bi2 = ObjectWrap::Unwrap<BigInt>(args[1]->ToObject());
508 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
509 mpz_init(*res);
510 mpz_powm(*res, *bigint->bigint_, *bi1->bigint_, *bi2->bigint_);
511
512 WRAP_RESULT(res, result);
513
514 return scope.Close(result);
e89bdf8 @substack untested power and modulo functions
authored
515 }
516
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
517 Handle<Value>
518 BigInt::Upowm(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
519 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
520 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
521 HandleScope scope;
d0f9505 @substack no tabs
authored
522
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
523 REQ_UINT64_ARG(0, x);
524 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[1]->ToObject());
525 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
526 mpz_init(*res);
527 mpz_powm_ui(*res, *bigint->bigint_, x, *bi->bigint_);
528
529 WRAP_RESULT(res, result);
530
531 return scope.Close(result);
e89bdf8 @substack untested power and modulo functions
authored
532 }
533
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
534 Handle<Value>
535 BigInt::Upow(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
536 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
537 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
538 HandleScope scope;
539
540 REQ_UINT64_ARG(0, x);
541 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
542 mpz_init(*res);
543 mpz_pow_ui(*res, *bigint->bigint_, x);
544
545 WRAP_RESULT(res, result);
d0f9505 @substack no tabs
authored
546
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
547 return scope.Close(result);
e89bdf8 @substack untested power and modulo functions
authored
548 }
549
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
550 /*
551 * This makes no sense? It doesn't act on the object but is a
552 * prototype method.
553 */
554 Handle<Value>
555 BigInt::Uupow(const Arguments& args)
556 {
557 HandleScope scope;
558
559 REQ_UINT64_ARG(0, x);
560 REQ_UINT64_ARG(1, y);
561 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
562 mpz_init(*res);
563 mpz_ui_pow_ui(*res, x, y);
564
565 WRAP_RESULT(res, result);
566
567 return scope.Close(result);
e89bdf8 @substack untested power and modulo functions
authored
568 }
6a80d7c @substack toNumber and buggy rand()
authored
569
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
570 Handle<Value>
571 BigInt::Brand0(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
572 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
573 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
574 HandleScope scope;
575
576 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
577 mpz_init(*res);
578
579 if(randstate == NULL) {
580 randstate = (gmp_randstate_t *) malloc(sizeof(gmp_randstate_t));
581 gmp_randinit_default(*randstate);
582 unsigned long seed = rand() + (time(NULL) * 1000) + clock();
583 gmp_randseed_ui(*randstate, seed);
584 }
585
586 mpz_urandomm(*res, *randstate, *bigint->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
587
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
588 WRAP_RESULT(res, result);
589
590 return scope.Close(result);
6a80d7c @substack toNumber and buggy rand()
authored
591 }
28fbfbd @substack primality testing, tested
authored
592
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
593 Handle<Value>
594 BigInt::Probprime(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
595 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
596 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
597 HandleScope scope;
598
599 REQ_UINT32_ARG(0, reps);
600
601 return scope.Close(Number::New(mpz_probab_prime_p(*bigint->bigint_, reps)));
602 }
603
604 Handle<Value>
605 BigInt::Nextprime(const Arguments& args)
606 {
607 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
608 HandleScope scope;
609
610 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
611 mpz_init(*res);
612 mpz_nextprime(*res, *bigint->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
613
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
614 WRAP_RESULT(res, result);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
615
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
616 return scope.Close(result);
28fbfbd @substack primality testing, tested
authored
617 }
618
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
619 Handle<Value>
620 BigInt::Bcompare(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
621 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
622 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
623 HandleScope scope;
624
625 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
c234211 @draggor Changing from FFI to c++ node module
draggor authored
626
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
627 return scope.Close(Number::New(mpz_cmp(*bigint->bigint_, *bi->bigint_)));
28fbfbd @substack primality testing, tested
authored
628 }
004df54 @substack untested comparison operators
authored
629
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
630 Handle<Value>
631 BigInt::Scompare(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
632 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
633 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
634 HandleScope scope;
635
636 REQ_INT64_ARG(0, x);
637
638 return scope.Close(Number::New(mpz_cmp_si(*bigint->bigint_, x)));
004df54 @substack untested comparison operators
authored
639 }
640
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
641 Handle<Value>
642 BigInt::Ucompare(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
643 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
644 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
645 HandleScope scope;
646
647 REQ_UINT64_ARG(0, x);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
648
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
649 return scope.Close(Number::New(mpz_cmp_ui(*bigint->bigint_, x)));
004df54 @substack untested comparison operators
authored
650 }
651
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
652 Handle<Value>
653 BigInt::Band(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
654 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
655 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
656 HandleScope scope;
657
658 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
659 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
660 mpz_init(*res);
661 mpz_and(*res, *bigint->bigint_, *bi->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
662
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
663 WRAP_RESULT(res, result);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
664
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
665 return scope.Close(result);
004df54 @substack untested comparison operators
authored
666 }
96dca75 @substack multiplicative inverse with modulo, tested
authored
667
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
668 Handle<Value>
669 BigInt::Bor(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
670 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
671 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
672 HandleScope scope;
c234211 @draggor Changing from FFI to c++ node module
draggor authored
673
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
674 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
675 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
676 mpz_init(*res);
677 mpz_ior(*res, *bigint->bigint_, *bi->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
678
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
679 WRAP_RESULT(res, result);
680
681 return scope.Close(result);
552f97c @substack bitwise operators
authored
682 }
683
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
684 Handle<Value>
685 BigInt::Bxor(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
686 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
687 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
688 HandleScope scope;
689
690 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
691 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
692 mpz_init(*res);
693 mpz_xor(*res, *bigint->bigint_, *bi->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
694
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
695 WRAP_RESULT(res, result);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
696
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
697 return scope.Close(result);
552f97c @substack bitwise operators
authored
698 }
699
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
700 Handle<Value>
701 BigInt::Binvertm(const Arguments& args)
c234211 @draggor Changing from FFI to c++ node module
draggor authored
702 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
703 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
704 HandleScope scope;
705
706 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
707 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
708 mpz_init(*res);
709 mpz_invert(*res, *bigint->bigint_, *bi->bigint_);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
710
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
711 WRAP_RESULT(res, result);
c234211 @draggor Changing from FFI to c++ node module
draggor authored
712
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
713 return scope.Close(result);
552f97c @substack bitwise operators
authored
714 }
715
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
716 Handle<Value>
717 BigInt::Bsqrt(const Arguments& args)
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
718 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
719 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
720 HandleScope scope;
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
721
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
722 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
723 mpz_init(*res);
724 mpz_sqrt(*res, *bigint->bigint_);
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
725
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
726 WRAP_RESULT(res, result);
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
727
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
728 return scope.Close(result);
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
729 }
730
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
731 Handle<Value>
732 BigInt::Broot(const Arguments& args)
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
733 {
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
734 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
735 HandleScope scope;
736
737 REQ_UINT64_ARG(0, x);
738 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
739 mpz_init(*res);
740 mpz_root(*res, *bigint->bigint_, x);
741
742 WRAP_RESULT(res, result);
743
744 return scope.Close(result);
745 }
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
746
88e5265 @benadida added bitLength method
benadida authored
747 Handle<Value>
748 BigInt::BitLength(const Arguments& args)
749 {
750 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
751 HandleScope scope;
752
753 size_t size = mpz_sizeinbase(*bigint->bigint_, 2);
754
755 Handle<Value> result = Integer::New(size);
756
757 return scope.Close(result);
758 }
759
2ac68fb @benadida added gcd method
benadida authored
760 Handle<Value>
761 BigInt::Bgcd(const Arguments& args)
762 {
763 BigInt *bigint = ObjectWrap::Unwrap<BigInt>(args.This());
764 HandleScope scope;
765
766 BigInt *bi = ObjectWrap::Unwrap<BigInt>(args[0]->ToObject());
767 mpz_t *res = (mpz_t *) malloc(sizeof(mpz_t));
768 mpz_init(*res);
769 mpz_gcd(*res, *bigint->bigint_, *bi->bigint_);
770
771 WRAP_RESULT(res, result);
772
773 return scope.Close(result);
774 }
775
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
776 static Handle<Value>
777 SetJSConditioner(const Arguments& args)
778 {
779 HandleScope scope;
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
780
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
781 BigInt::SetJSConditioner(Persistent<Function>::New(Local<Function>::Cast(args[0])));
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
782
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
783 return Undefined();
c65bc45 @draggor Adding sqrt and root functions, blocking .*.swp in .gitignore
draggor authored
784 }
785
c234211 @draggor Changing from FFI to c++ node module
draggor authored
786 extern "C" void
439a8b3 @draggor Merging rand changes, changing to c++ object style for module
draggor authored
787 init (Handle<Object> target)
788 {
789 HandleScope scope;
790
791 BigInt::Initialize(target);
792 NODE_SET_METHOD(target, "setJSConditioner", SetJSConditioner);
96dca75 @substack multiplicative inverse with modulo, tested
authored
793 }
52f3df2 @lloyd use NODE_MODULE() macro, required for node.js 0.10.0 (and winblows too)
lloyd authored
794
795 NODE_MODULE(bigint, init);
Something went wrong with that request. Please try again.