fix tests
This commit is contained in:
parent
3d67721fb5
commit
06e4b83943
|
@ -51,9 +51,9 @@ var j_lm = ((canary & 0xffffff) == 0xefcafe);
|
||||||
// (public) Constructor
|
// (public) Constructor
|
||||||
|
|
||||||
function BigInteger(a, b, c) {
|
function BigInteger(a, b, c) {
|
||||||
if (a !== null)
|
if (a != null)
|
||||||
if ("number" == typeof a) this.fromNumber(a, b, c);
|
if ("number" == typeof a) this.fromNumber(a, b, c);
|
||||||
else if (b === null && "string" != typeof a) this.fromString(a, 256);
|
else if (b == null && "string" != typeof a) this.fromString(a, 256);
|
||||||
else this.fromString(a, b);
|
else this.fromString(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ BigInteger.prototype.F2 = 2 * dbits - BI_FP;
|
||||||
|
|
||||||
// Digit conversions
|
// Digit conversions
|
||||||
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
|
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
var BI_RC = [];
|
var BI_RC = new Array();
|
||||||
var rr, vv;
|
var rr, vv;
|
||||||
rr = "0".charCodeAt(0);
|
rr = "0".charCodeAt(0);
|
||||||
for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
|
for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
|
||||||
|
@ -153,7 +153,7 @@ function int2char(n) {
|
||||||
|
|
||||||
function intAt(s, i) {
|
function intAt(s, i) {
|
||||||
var c = BI_RC[s.charCodeAt(i)];
|
var c = BI_RC[s.charCodeAt(i)];
|
||||||
return (c === null) ? -1 : c;
|
return (c == null) ? -1 : c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (protected) copy this to r
|
// (protected) copy this to r
|
||||||
|
@ -208,7 +208,7 @@ function bnpFromString(s, b) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mi = false;
|
mi = false;
|
||||||
if (sh === 0)
|
if (sh == 0)
|
||||||
this[this.t++] = x;
|
this[this.t++] = x;
|
||||||
else if (sh + k > this.DB) {
|
else if (sh + k > this.DB) {
|
||||||
this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
|
this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
|
||||||
|
@ -218,7 +218,7 @@ function bnpFromString(s, b) {
|
||||||
sh += k;
|
sh += k;
|
||||||
if (sh >= this.DB) sh -= this.DB;
|
if (sh >= this.DB) sh -= this.DB;
|
||||||
}
|
}
|
||||||
if (k == 8 && (s[0] & 0x80) !== 0) {
|
if (k == 8 && (s[0] & 0x80) != 0) {
|
||||||
this.s = -1;
|
this.s = -1;
|
||||||
if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
|
if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
|
||||||
}
|
}
|
||||||
|
@ -290,11 +290,11 @@ function bnAbs() {
|
||||||
|
|
||||||
function bnCompareTo(a) {
|
function bnCompareTo(a) {
|
||||||
var r = this.s - a.s;
|
var r = this.s - a.s;
|
||||||
if (r !== 0) return r;
|
if (r != 0) return r;
|
||||||
var i = this.t;
|
var i = this.t;
|
||||||
r = i - a.t;
|
r = i - a.t;
|
||||||
if (r !== 0) return r;
|
if (r != 0) return r;
|
||||||
while (--i >= 0) if ((r = this[i] - a[i]) !== 0) return r;
|
while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,23 +303,23 @@ function bnCompareTo(a) {
|
||||||
function nbits(x) {
|
function nbits(x) {
|
||||||
var r = 1,
|
var r = 1,
|
||||||
t;
|
t;
|
||||||
if ((t = x >>> 16) !== 0) {
|
if ((t = x >>> 16) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
r += 16;
|
r += 16;
|
||||||
}
|
}
|
||||||
if ((t = x >> 8) !== 0) {
|
if ((t = x >> 8) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
r += 8;
|
r += 8;
|
||||||
}
|
}
|
||||||
if ((t = x >> 4) !== 0) {
|
if ((t = x >> 4) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
r += 4;
|
r += 4;
|
||||||
}
|
}
|
||||||
if ((t = x >> 2) !== 0) {
|
if ((t = x >> 2) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
r += 2;
|
r += 2;
|
||||||
}
|
}
|
||||||
if ((t = x >> 1) !== 0) {
|
if ((t = x >> 1) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
r += 1;
|
r += 1;
|
||||||
}
|
}
|
||||||
|
@ -469,11 +469,11 @@ function bnpDivRemTo(m, q, r) {
|
||||||
if (pm.t <= 0) return;
|
if (pm.t <= 0) return;
|
||||||
var pt = this.abs();
|
var pt = this.abs();
|
||||||
if (pt.t < pm.t) {
|
if (pt.t < pm.t) {
|
||||||
if (q !== null) q.fromInt(0);
|
if (q != null) q.fromInt(0);
|
||||||
if (r !== null) this.copyTo(r);
|
if (r != null) this.copyTo(r);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (r === null) r = nbi();
|
if (r == null) r = nbi();
|
||||||
var y = nbi(),
|
var y = nbi(),
|
||||||
ts = this.s,
|
ts = this.s,
|
||||||
ms = m.s;
|
ms = m.s;
|
||||||
|
@ -487,14 +487,14 @@ function bnpDivRemTo(m, q, r) {
|
||||||
}
|
}
|
||||||
var ys = y.t;
|
var ys = y.t;
|
||||||
var y0 = y[ys - 1];
|
var y0 = y[ys - 1];
|
||||||
if (y0 === 0) return;
|
if (y0 == 0) return;
|
||||||
var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
|
var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
|
||||||
var d1 = this.FV / yt,
|
var d1 = this.FV / yt,
|
||||||
d2 = (1 << this.F1) / yt,
|
d2 = (1 << this.F1) / yt,
|
||||||
e = 1 << this.F2;
|
e = 1 << this.F2;
|
||||||
var i = r.t,
|
var i = r.t,
|
||||||
j = i - ys,
|
j = i - ys,
|
||||||
t = (q === null) ? nbi() : q;
|
t = (q == null) ? nbi() : q;
|
||||||
y.dlShiftTo(j, t);
|
y.dlShiftTo(j, t);
|
||||||
if (r.compareTo(t) >= 0) {
|
if (r.compareTo(t) >= 0) {
|
||||||
r[r.t++] = 1;
|
r[r.t++] = 1;
|
||||||
|
@ -512,7 +512,7 @@ function bnpDivRemTo(m, q, r) {
|
||||||
while (r[i] < --qd) r.subTo(t, r);
|
while (r[i] < --qd) r.subTo(t, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q !== null) {
|
if (q != null) {
|
||||||
r.drShiftTo(ys, q);
|
r.drShiftTo(ys, q);
|
||||||
if (ts != ms) BigInteger.ZERO.subTo(q, q);
|
if (ts != ms) BigInteger.ZERO.subTo(q, q);
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ Classic.prototype.sqrTo = cSqrTo;
|
||||||
function bnpInvDigit() {
|
function bnpInvDigit() {
|
||||||
if (this.t < 1) return 0;
|
if (this.t < 1) return 0;
|
||||||
var x = this[0];
|
var x = this[0];
|
||||||
if ((x & 1) === 0) return 0;
|
if ((x & 1) == 0) return 0;
|
||||||
var y = x & 3; // y == 1/x mod 2^2
|
var y = x & 3; // y == 1/x mod 2^2
|
||||||
y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
|
y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
|
||||||
y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
|
y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
|
||||||
|
@ -668,7 +668,7 @@ Montgomery.prototype.sqrTo = montSqrTo;
|
||||||
// (protected) true iff this is even
|
// (protected) true iff this is even
|
||||||
|
|
||||||
function bnpIsEven() {
|
function bnpIsEven() {
|
||||||
return ((this.t > 0) ? (this[0] & 1) : this.s) === 0;
|
return ((this.t > 0) ? (this[0] & 1) : this.s) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
|
// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
|
||||||
|
@ -802,9 +802,9 @@ function bnClone() {
|
||||||
function bnIntValue() {
|
function bnIntValue() {
|
||||||
if (this.s < 0) {
|
if (this.s < 0) {
|
||||||
if (this.t == 1) return this[0] - this.DV;
|
if (this.t == 1) return this[0] - this.DV;
|
||||||
else if (this.t === 0) return -1;
|
else if (this.t == 0) return -1;
|
||||||
} else if (this.t == 1) return this[0];
|
} else if (this.t == 1) return this[0];
|
||||||
else if (this.t === 0) return 0;
|
else if (this.t == 0) return 0;
|
||||||
// assumes 16 < DB < 32
|
// assumes 16 < DB < 32
|
||||||
return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
|
return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
|
||||||
}
|
}
|
||||||
|
@ -812,13 +812,13 @@ function bnIntValue() {
|
||||||
// (public) return value as byte
|
// (public) return value as byte
|
||||||
|
|
||||||
function bnByteValue() {
|
function bnByteValue() {
|
||||||
return (this.t === 0) ? this.s : (this[0] << 24) >> 24;
|
return (this.t == 0) ? this.s : (this[0] << 24) >> 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (public) return value as short (assumes DB>=16)
|
// (public) return value as short (assumes DB>=16)
|
||||||
|
|
||||||
function bnShortValue() {
|
function bnShortValue() {
|
||||||
return (this.t === 0) ? this.s : (this[0] << 16) >> 16;
|
return (this.t == 0) ? this.s : (this[0] << 16) >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (protected) return x s.t. r^x < DV
|
// (protected) return x s.t. r^x < DV
|
||||||
|
@ -838,8 +838,8 @@ function bnSigNum() {
|
||||||
// (protected) convert to radix string
|
// (protected) convert to radix string
|
||||||
|
|
||||||
function bnpToRadix(b) {
|
function bnpToRadix(b) {
|
||||||
if (b === null) b = 10;
|
if (b == null) b = 10;
|
||||||
if (this.signum() === 0 || b < 2 || b > 36) return "0";
|
if (this.signum() == 0 || b < 2 || b > 36) return "0";
|
||||||
var cs = this.chunkSize(b);
|
var cs = this.chunkSize(b);
|
||||||
var a = Math.pow(b, cs);
|
var a = Math.pow(b, cs);
|
||||||
var d = nbv(a),
|
var d = nbv(a),
|
||||||
|
@ -858,7 +858,7 @@ function bnpToRadix(b) {
|
||||||
|
|
||||||
function bnpFromRadix(s, b) {
|
function bnpFromRadix(s, b) {
|
||||||
this.fromInt(0);
|
this.fromInt(0);
|
||||||
if (b === null) b = 10;
|
if (b == null) b = 10;
|
||||||
var cs = this.chunkSize(b);
|
var cs = this.chunkSize(b);
|
||||||
var d = Math.pow(b, cs),
|
var d = Math.pow(b, cs),
|
||||||
mi = false,
|
mi = false,
|
||||||
|
@ -867,7 +867,7 @@ function bnpFromRadix(s, b) {
|
||||||
for (var i = 0; i < s.length; ++i) {
|
for (var i = 0; i < s.length; ++i) {
|
||||||
var x = intAt(s, i);
|
var x = intAt(s, i);
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
if (s.charAt(i) == "-" && this.signum() === 0) mi = true;
|
if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
w = b * w + x;
|
w = b * w + x;
|
||||||
|
@ -903,7 +903,7 @@ function bnpFromNumber(a, b, c) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// new BigInteger(int,RNG)
|
// new BigInteger(int,RNG)
|
||||||
var x = [],
|
var x = new Array(),
|
||||||
t = a & 7;
|
t = a & 7;
|
||||||
x.length = (a >> 3) + 1;
|
x.length = (a >> 3) + 1;
|
||||||
b.nextBytes(x);
|
b.nextBytes(x);
|
||||||
|
@ -917,7 +917,7 @@ function bnpFromNumber(a, b, c) {
|
||||||
|
|
||||||
function bnToByteArray() {
|
function bnToByteArray() {
|
||||||
var i = this.t,
|
var i = this.t,
|
||||||
r = [];
|
r = new Array();
|
||||||
r[0] = this.s;
|
r[0] = this.s;
|
||||||
var p = this.DB - (i * this.DB) % 8,
|
var p = this.DB - (i * this.DB) % 8,
|
||||||
d, k = 0;
|
d, k = 0;
|
||||||
|
@ -944,7 +944,7 @@ function bnToByteArray() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bnEquals(a) {
|
function bnEquals(a) {
|
||||||
return (this.compareTo(a) === 0);
|
return (this.compareTo(a) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bnMin(a) {
|
function bnMin(a) {
|
||||||
|
@ -1052,25 +1052,25 @@ function bnShiftRight(n) {
|
||||||
// return index of lowest 1-bit in x, x < 2^31
|
// return index of lowest 1-bit in x, x < 2^31
|
||||||
|
|
||||||
function lbit(x) {
|
function lbit(x) {
|
||||||
if (x === 0) return -1;
|
if (x == 0) return -1;
|
||||||
var r = 0;
|
var r = 0;
|
||||||
if ((x & 0xffff) === 0) {
|
if ((x & 0xffff) == 0) {
|
||||||
x >>= 16;
|
x >>= 16;
|
||||||
r += 16;
|
r += 16;
|
||||||
}
|
}
|
||||||
if ((x & 0xff) === 0) {
|
if ((x & 0xff) == 0) {
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
r += 8;
|
r += 8;
|
||||||
}
|
}
|
||||||
if ((x & 0xf) === 0) {
|
if ((x & 0xf) == 0) {
|
||||||
x >>= 4;
|
x >>= 4;
|
||||||
r += 4;
|
r += 4;
|
||||||
}
|
}
|
||||||
if ((x & 3) === 0) {
|
if ((x & 3) == 0) {
|
||||||
x >>= 2;
|
x >>= 2;
|
||||||
r += 2;
|
r += 2;
|
||||||
}
|
}
|
||||||
if ((x & 1) === 0)++r;
|
if ((x & 1) == 0)++r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1078,7 @@ function lbit(x) {
|
||||||
|
|
||||||
function bnGetLowestSetBit() {
|
function bnGetLowestSetBit() {
|
||||||
for (var i = 0; i < this.t; ++i)
|
for (var i = 0; i < this.t; ++i)
|
||||||
if (this[i] !== 0) return i * this.DB + lbit(this[i]);
|
if (this[i] != 0) return i * this.DB + lbit(this[i]);
|
||||||
if (this.s < 0) return this.t * this.DB;
|
if (this.s < 0) return this.t * this.DB;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1087,7 +1087,7 @@ function bnGetLowestSetBit() {
|
||||||
|
|
||||||
function cbit(x) {
|
function cbit(x) {
|
||||||
var r = 0;
|
var r = 0;
|
||||||
while (x !== 0) {
|
while (x != 0) {
|
||||||
x &= x - 1;
|
x &= x - 1;
|
||||||
++r;
|
++r;
|
||||||
}
|
}
|
||||||
|
@ -1107,8 +1107,8 @@ function bnBitCount() {
|
||||||
|
|
||||||
function bnTestBit(n) {
|
function bnTestBit(n) {
|
||||||
var j = Math.floor(n / this.DB);
|
var j = Math.floor(n / this.DB);
|
||||||
if (j >= this.t) return (this.s !== 0);
|
if (j >= this.t) return (this.s != 0);
|
||||||
return ((this[j] & (1 << (n % this.DB))) !== 0);
|
return ((this[j] & (1 << (n % this.DB))) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// (protected) this op (1<<n)
|
// (protected) this op (1<<n)
|
||||||
|
@ -1240,7 +1240,7 @@ function bnpDMultiply(n) {
|
||||||
// (protected) this += n << w words, this >= 0
|
// (protected) this += n << w words, this >= 0
|
||||||
|
|
||||||
function bnpDAddOffset(n, w) {
|
function bnpDAddOffset(n, w) {
|
||||||
if (n === 0) return;
|
if (n == 0) return;
|
||||||
while (this.t <= w) this[this.t++] = 0;
|
while (this.t <= w) this[this.t++] = 0;
|
||||||
this[w] += n;
|
this[w] += n;
|
||||||
while (this[w] >= this.DV) {
|
while (this[w] >= this.DV) {
|
||||||
|
@ -1386,7 +1386,7 @@ function bnModPow(e, m) {
|
||||||
z = new Montgomery(m);
|
z = new Montgomery(m);
|
||||||
|
|
||||||
// precomputation
|
// precomputation
|
||||||
var g = [],
|
var g = new Array(),
|
||||||
n = 3,
|
n = 3,
|
||||||
k1 = k - 1,
|
k1 = k - 1,
|
||||||
km = (1 << k) - 1;
|
km = (1 << k) - 1;
|
||||||
|
@ -1414,7 +1414,7 @@ function bnModPow(e, m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
n = k;
|
n = k;
|
||||||
while ((w & 1) === 0) {
|
while ((w & 1) == 0) {
|
||||||
w >>= 1;
|
w >>= 1;
|
||||||
--n;
|
--n;
|
||||||
}
|
}
|
||||||
|
@ -1440,7 +1440,7 @@ function bnModPow(e, m) {
|
||||||
z.mulTo(r2, g[w], r);
|
z.mulTo(r2, g[w], r);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (j >= 0 && (e[j] & (1 << i)) === 0) {
|
while (j >= 0 && (e[j] & (1 << i)) == 0) {
|
||||||
z.sqrTo(r, r2);
|
z.sqrTo(r, r2);
|
||||||
t = r;
|
t = r;
|
||||||
r = r2;
|
r = r2;
|
||||||
|
@ -1494,7 +1494,7 @@ function bnpModInt(n) {
|
||||||
var d = this.DV % n,
|
var d = this.DV % n,
|
||||||
r = (this.s < 0) ? n - 1 : 0;
|
r = (this.s < 0) ? n - 1 : 0;
|
||||||
if (this.t > 0)
|
if (this.t > 0)
|
||||||
if (d === 0) r = this[0] % n;
|
if (d == 0) r = this[0] % n;
|
||||||
else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
|
else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -1503,14 +1503,14 @@ function bnpModInt(n) {
|
||||||
|
|
||||||
function bnModInverse(m) {
|
function bnModInverse(m) {
|
||||||
var ac = m.isEven();
|
var ac = m.isEven();
|
||||||
if ((this.isEven() && ac) || m.signum() === 0) return BigInteger.ZERO;
|
if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
|
||||||
var u = m.clone(),
|
var u = m.clone(),
|
||||||
v = this.clone();
|
v = this.clone();
|
||||||
var a = nbv(1),
|
var a = nbv(1),
|
||||||
b = nbv(0),
|
b = nbv(0),
|
||||||
c = nbv(0),
|
c = nbv(0),
|
||||||
d = nbv(1);
|
d = nbv(1);
|
||||||
while (u.signum() !== 0) {
|
while (u.signum() != 0) {
|
||||||
while (u.isEven()) {
|
while (u.isEven()) {
|
||||||
u.rShiftTo(1, u);
|
u.rShiftTo(1, u);
|
||||||
if (ac) {
|
if (ac) {
|
||||||
|
@ -1543,7 +1543,7 @@ function bnModInverse(m) {
|
||||||
d.subTo(b, d);
|
d.subTo(b, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (v.compareTo(BigInteger.ONE) !== 0) return BigInteger.ZERO;
|
if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
|
||||||
if (d.compareTo(m) >= 0) return d.subtract(m);
|
if (d.compareTo(m) >= 0) return d.subtract(m);
|
||||||
if (d.signum() < 0) d.addTo(m, d);
|
if (d.signum() < 0) d.addTo(m, d);
|
||||||
else return d;
|
else return d;
|
||||||
|
@ -1578,7 +1578,7 @@ function bnIsProbablePrime(t) {
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
|
while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
|
||||||
m = x.modInt(m);
|
m = x.modInt(m);
|
||||||
while (i < j) if (m % lowprimes[i++] === 0) return false;
|
while (i < j) if (m % lowprimes[i++] == 0) return false;
|
||||||
}
|
}
|
||||||
return x.millerRabin(t);
|
return x.millerRabin(t);
|
||||||
}
|
}
|
||||||
|
@ -1588,23 +1588,23 @@ function bnIsProbablePrime(t) {
|
||||||
function nbits(x) {
|
function nbits(x) {
|
||||||
var n = 1,
|
var n = 1,
|
||||||
t;
|
t;
|
||||||
if ((t = x >>> 16) !== 0) {
|
if ((t = x >>> 16) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
n += 16;
|
n += 16;
|
||||||
}
|
}
|
||||||
if ((t = x >> 8) !== 0) {
|
if ((t = x >> 8) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
n += 8;
|
n += 8;
|
||||||
}
|
}
|
||||||
if ((t = x >> 4) !== 0) {
|
if ((t = x >> 4) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
n += 4;
|
n += 4;
|
||||||
}
|
}
|
||||||
if ((t = x >> 2) !== 0) {
|
if ((t = x >> 2) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
n += 2;
|
n += 2;
|
||||||
}
|
}
|
||||||
if ((t = x >> 1) !== 0) {
|
if ((t = x >> 1) != 0) {
|
||||||
x = t;
|
x = t;
|
||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
|
@ -1641,13 +1641,13 @@ function bnpMillerRabin(t) {
|
||||||
bases.push(j);
|
bases.push(j);
|
||||||
a.fromInt(j);
|
a.fromInt(j);
|
||||||
var y = a.modPow(r, this);
|
var y = a.modPow(r, this);
|
||||||
if (y.compareTo(BigInteger.ONE) !== 0 && y.compareTo(n1) !== 0) {
|
if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
|
||||||
j = 1;
|
var j = 1;
|
||||||
while (j++ < k && y.compareTo(n1) !== 0) {
|
while (j++ < k && y.compareTo(n1) != 0) {
|
||||||
y = y.modPowInt(2, this);
|
y = y.modPowInt(2, this);
|
||||||
if (y.compareTo(BigInteger.ONE) === 0) return false;
|
if (y.compareTo(BigInteger.ONE) == 0) return false;
|
||||||
}
|
}
|
||||||
if (y.compareTo(n1) !== 0) return false;
|
if (y.compareTo(n1) != 0) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user