Launch Week Day 3: Introducing Organization Notifications in Socket.Learn More
Socket
Book a DemoSign in
Socket

big-rational

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

big-rational - npm Package Compare versions

Comparing version
0.9.8
to
0.9.9
+3
.gitmodules
[submodule "BigInteger.js"]
path = BigInteger.js
url = git@github.com:peterolson/BigInteger.js.git
language: node_js
node_js:
- "0.11"
- "0.10"

Sorry, the diff of this file is too big to display

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Cache-control" content="no-cache">
<title>Big integer benchmarks</title>
<style>
img.wait {
width: 25px;
}
table {
border-collapse: collapse;
}
td, th {
border: 1px solid black;
padding: 0 5px 0 5px;
text-align: center;
}
td:last-child {
text-align: left;
}
body {
background-color: #eee;
}
#container {
border: 1px solid black;
border-radius: 15px 15px;
background-color: #fff;
width: 800px;
margin: 0 auto;
padding: 10px;
}
div.graph span {
display: inline-block;
height: 10px;
overflow: hidden;
background-color: #00AA00;
}
div.graph span.rme {
background-color: #FF8800;
}
#loading {
position: fixed;
left: 40%;
top: 40%;
width: 300px;
height: 100px;
line-height: 100px;
background-color: white;
border: 2px solid black;
text-align: center;
font-weight: bolder;
}
.indent {
margin-left: 20px;
}
</style>
</head>
<body>
<div id="loading">Please wait for libraries to load... <span id="loaded">0</span>/<span id="total"></span></div>
<div id="container">
<h1>Big integer benchmarks</h1>
Some performance benchmarks for different libraries that do arbitrary precision integer arithmetic. Keep in mind that the results shown here are only a rough estimate of the relative performance and can change significantly from run to run, as well as across different runtime environments.<br />
<button id="btnRunAll">Run all benchmarks</button>
<div id="benchmarks"></div>
</div>
<script src="tests.js"></script>
<script src="index.js"></script>
</body>
</html>
(function () {
var benchmarks = libraries["Peter Olson BigInteger.js"].tests,
_benchmarks = document.getElementById("benchmarks");
var group;
for (var i in benchmarks) {
var split = i.split(": "), thisGroup = split[0], title = split[1], html = "";
if (thisGroup != group) {
html += "<h2 id='" + thisGroup + "'>" + thisGroup + "<br><button class='btnBenchmarkGroup' title='" + thisGroup + "'>Run '" + thisGroup + "' benchmarks</button></h2>";
group = thisGroup;
}
html += "<div class='indent'><h3 title='" + i + "'>" + i + "<br><button class='btnBenchmark'>Run benchmark</button></h2>";
html += "<table><tr><th>Library</th><th>Code</th><th>Performance</th></tr>";
for (var j in libraries) {
var lib = libraries[j];
if (!lib.tests[i]) continue;
html += "<tr><td><a href='" + lib.projectURL + "'>" + j + "</a></td><td><pre>" + lib.tests[i] + "</pre></td><td>-</td></tr>";
}
html += "</table></div>";
_benchmarks.innerHTML += html;
}
var buttons = document.getElementsByClassName("btnBenchmark");
for (var i = 0; i < buttons.length; i++) {
buttons[i].onclick = btnBenchmark_click;
}
buttons = document.getElementsByClassName("btnBenchmarkGroup");
for (var i = 0; i < buttons.length; i++) {
buttons[i].onclick = btnBenchmarkGroup_click;
}
function btnBenchmark_click() {
var test = this.parentElement.title;
runTest(test);
}
function btnBenchmarkGroup_click() {
var group = this.title;
var tests = [];
for (var i in benchmarks) {
if (i.split(": ")[0] === group) tests.push(i);
}
runTests(tests);
}
document.getElementById("btnRunAll").onclick = function () {
var tests = [];
for (var i in benchmarks) tests.push(i);
runTests(tests);
}
function runTest(test, callback) {
var libs = [];
for (var i in libraries) {
if (libraries[i].tests[test]) libs.push(libraries[i]);
displayPerformance(libraries[i], {
name: test,
desc: "<img class='wait' src='wait.gif'>"
});
}
var i = 0;
(function f() {
if (i >= libs.length) {
if (callback) callback();
return;
}
testLibrary(libs[i++], [test], f);
})();
}
function runTests(tests) {
var i = 0;
(function f() {
if (i < tests.length) {
runTest(tests[i++], f);
}
})();
}
function displayPerformance(library, data) {
var test = data.name;
var h3s = document.getElementsByTagName("h3"), div;
for (var i = 0; i < h3s.length; i++) {
if (h3s[i].title === test) div = h3s[i].parentElement;
}
var table = div.getElementsByTagName("table")[0];
var trs = table.rows;
for (var i = 0; i < trs.length; i++) {
if (trs[i].innerHTML.indexOf(library.projectURL) !== -1) break;
}
if (i >= trs.length) return;
var td = trs[i].cells[2];
td.innerHTML = data.desc;
if (data.stats) {
td.innerHTML += "<div class='graph'></div>";
trs[i].stats = data.stats;
sortRows(table);
}
}
function sortRows(table) {
var rows = table.rows;
var newRows = [];
for (var i = 1; i < rows.length; i++) newRows.push({
stats: rows[i].stats,
HTML: rows[i].innerHTML
});
newRows.sort(function (a, b) {
if (a.stats && !b.stats) return -1;
if (b.stats && !a.stats) return 1;
if (!a.stats) return 0;
if (!a.stats.mean) return 1;
if (!b.stats.mean) return -1;
return a.stats.mean - b.stats.mean;
});
if (!newRows[0].stats) return;
var mean = 1 / newRows[0].stats.mean,
rme = newRows[0].stats.rme;
var max = mean;
for (var i = 1; i < rows.length; i++) {
rows[i].innerHTML = newRows[i - 1].HTML;
rows[i].stats = newRows[i - 1].stats;
}
for (var i = 1; i < rows.length; i++) {
showGraph(rows[i], max);
}
}
function showGraph(row, max) {
var cell = row.cells[2],
stats = row.stats,
div = cell.getElementsByTagName("div")[0];
if (!stats || !div || !stats.mean) return;
var mean = 1 / stats.mean,
rme = stats.rme;
var variance = (mean * rme / 100);
var left = Math.round(100 * (mean - variance) / max),
rme = Math.round(100 * variance / max);
left = left < 1 ? "1px" : left + "%";
div.innerHTML = "<span class='left' style='width:" + left + "'></span>" +
"<span class='rme' style='width:" + rme + "%'></span>";
}
var workers = {};
var loaded = 0, total = 0;
for (i in libraries) {
initWorker(libraries[i]);
total++;
}
function testLibrary(library, tests, fn) {
var url = library.projectURL, timeout;
var worker = workers[url];
library.testsToRun = tests;
library.timeout = 10000;
worker.postMessage(library);
worker.onmessage = function (e) {
clearTimeout(timeout);
var type = e.data.type;
if (type === "complete") {
fn();
return;
}
if (type === "cycle") {
displayPerformance(library, e.data);
}
};
timeout = setTimeout(function () {
worker.terminate();
library.testsToRun = null;
initWorker(library);
for (var i = 0; i < tests.length; i++) {
fn();
displayPerformance(library, {
name: tests[i],
stats: {
mean: 0
},
desc: "Test timed out."
});
}
}, library.timeout * 1.5);
}
function initWorker(library) {
var url = library.projectURL;
var worker = new Worker("testWorker.js?" + encodeURIComponent(url));
worker.postMessage(library);
worker.onmessage = function (e) {
if (e.data.type === "loaded") {
loaded++;
showLoaded();
}
}
workers[url] = worker;
}
function showLoaded() {
document.getElementById("loaded").innerHTML = loaded;
document.getElementById("total").innerHTML = total;
if (loaded === total) {
document.getElementById("loading").style.display = "none";
}
}
showLoaded();
})();
var libraries = (function () {
var a = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
b = "1234567890234567890134567890124567890123567890123467890123457890123456890123456790123456780123456789",
c = "98109840984098409156481068456541684065964819841065106865710397464513210416435401645030648036034063974065004951094209420942097421970490274195049120974210974209742190274092740492097420929892490974202241",
d = c + c + c + c + c + c + c + c + c + c,
e = d + d + d + d + d + d + d + d + d + d,
f = e + e + e,
c2 = a + b,
d2 = c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2,
e2 = d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2,
f2 = e2 + e2 + e2,
s1 = 12345,
s2 = 98765,
s3 = 5437654,
_5 = 5,
_22 = 22,
_23 = 23;
var vars = { a: a, b: b, c: c, d: d, e: e, f: f, c2: c2, d2: d2, e2: e2, f2: f2, s1: s1, s2: s2, s3: s3, _5: _5, _22: _22, _23: _23 };
var createInitialization = function (fName, radix) {
var str = "";
radix = radix || "";
for (var i in vars) {
str += i + "=" + fName + "('" + vars[i] + "'" + radix + ");" + i + "_str='" + vars[i] + "';";
}
return str;
};
var createOnCycle = function (f) {
var str = "";
for (var i in vars) {
str += f(i) + ";";
}
return str;
};
var tests = {
"Addition: large1 + large2": "a.add(b)",
"Addition: large + small": "a.add(s1)",
"Addition: small + large": "s1.add(a)",
"Addition: small1 + small2": "s1.add(s2)",
"Addition: 200 digits": "c.add(c2)",
"Addition: 2,000 digits": "d.add(d2)",
"Addition: 20,000 digits": "e.add(e2)",
"Addition: 60,000 digits": "f.add(f2)",
"Subtraction: large1 - large2": "b.minus(a)",
"Subtraction: large - small": "b.minus(s1)",
"Subtraction: small - large": "s1.minus(b)",
"Subtraction: small - small": "s2.minus(s1)",
"Subtraction: 200 digits": "c.minus(c2)",
"Subtraction: 2,000 digits": "d.minus(d2)",
"Subtraction: 20,000 digits": "e.minus(e2)",
"Subtraction: 60,000 digits": "f.minus(f2)",
"Multiplication: large * large": "a.times(b)",
"Multiplication: large * small": "a.times(s1)",
"Multiplication: small * large": "s1.times(a)",
"Multiplication: small1 * small2": "s1.times(s2)",
"Multiplication: 400 digits": "c.times(b)",
"Multiplication: 2,200 digits": "d.times(c)",
"Multiplication: 22,000 digits": "e.times(d)",
"Multiplication: 82,000 digits": "f.times(e)",
"Squaring: small": "s1.square()",
"Squaring: 200 digits": "a.square()",
"Squaring: 400 digits": "c.square()",
"Squaring: 4,000 digits": "d.square()",
"Squaring: 40,000 digits": "e.square()",
"Division: large1 / large2": "b.over(a)",
"Division: large / small": "a.over(s1)",
"Division: small / large": "s2.over(b)",
"Division: small / small": "s2.over(s1)",
"Division: 200 digits": "c.over(b)",
"Division: 2,000 digits": "d.over(c)",
"Division: 20,000 digits": "e.over(d)",
"Division: 60,000 digits": "f.over(e)",
"Exponentiation: 5 ^ 22": "_5.pow(_22)",
"Exponentiation: 5 ^ 23": "_5.pow(_23)",
"Exponentiation: 5 ^ 12345": "_5.pow(s1)",
"Exponentiation: 12345 ^ 12345": "s1.pow(s1)",
"parseInt: 5 decimal digits": "parseInt(s1_str, 10)",
"parseInt: 100 decimal digits": "parseInt(a_str, 10)",
"parseInt: 2,000 decimal digits": "parseInt(d_str, 10)",
"parseInt: 20,000 decimal digits": "parseInt(e_str, 10)",
"parseInt: 5 hex digits": "parseInt(s1_str, 16)",
"parseInt: 83 hex digits": "parseInt(a_str, 16)",
"parseInt: 1,661 hex digits": "parseInt(d_str, 16)",
"parseInt: 16,610 hex digits": "parseInt(e_str, 16)",
"toString: 5 decimal digits": "s1.toString(10)",
"toString: 100 decimal digits": "a.toString(10)",
"toString: 2,000 decimal digits": "d.toString(10)",
"toString: 20,000 decimal digits": "e.toString(10)",
"toString: 5 hex digits": "s2.toString(16)",
"toString: 83 hex digits": "a.toString(16)",
"toString: 1,661 hex digits": "d.toString(16)",
"toString: 16,610 hex digits": "e.toString(16)"
};
function generateTests(transformation, skip) {
skip = skip || [];
var t = {};
for (var i in tests) {
if (skip.indexOf(i.split(":")[0]) > -1) continue;
t[i] = transformation(tests[i]);
};
return t;
}
var libraries = {
"Peter Olson BigInteger.js": {
url: ["../BigInteger.js"],
projectURL: "https://github.com/peterolson/BigInteger.js",
onStart: createInitialization("bigInt"),
tests: generateTests(function (x) { return x.replace("parseInt", "bigInt"); })
},
"Yaffle BigInteger": {
url: ["https://rawgit.com/Yaffle/BigInteger/master/BigInteger.js"],
projectURL: "https://github.com/Yaffle/BigInteger",
onStart: createInitialization("BigInteger.parseInt"),
tests: generateTests(function (x) {
return x.replace(/\.add/g, "['BigInteger.add']")
.replace(/\.minus/g, "['BigInteger.subtract']")
.replace(/\.times/g, "['BigInteger.multiply']")
.replace(/\.over/g, "['BigInteger.divide']")
.replace(/(.+)\.square\(\)/g, "$1['BigInteger.multiply']($1)")
.replace(/\.toString/g, "['BigInteger.toString']")
.replace("parseInt", "BigInteger.parseInt");
}, ["Exponentiation"])
},
"Silent Matt BigInteger": {
url: ["https://rawgit.com/silentmatt/javascript-biginteger/master/biginteger.js"],
projectURL: "http://silentmatt.com/biginteger/",
onStart: createInitialization("BigInteger.parse"),
tests: generateTests(function (x) {
return x.replace(/\.minus/g, ".subtract")
.replace(/\.times/g, ".multiply")
.replace(/\.over/g, ".divide")
.replace("parseInt", "BigInteger.parse");
})
},
"Tom Wu jsbn": {
url: ["http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js", "http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn2.js"],
projectURL: "http://www-cs-students.stanford.edu/~tjw/jsbn/",
onStart: createInitialization("new BigInteger"),
tests: generateTests(function (x) {
return x.replace(/\.minus/g, ".subtract")
.replace(/\.times/g, ".multiply")
.replace(/\.over/g, ".divide")
.replace("parseInt", "new BigInteger");
})
},
"Fedor Indutny bn.js": {
url: ["https://rawgit.com/indutny/bn.js/master/lib/bn.js"],
projectURL: "https://github.com/indutny/bn.js",
onStart: createInitialization("new BN"),
tests: generateTests(function (x) {
return x.replace(/\.minus/g, ".sub")
.replace(/\.times/g, ".mul")
.replace(/(.+)\.square\(\)/g, "$1.mul($1)")
.replace(/\.over/g, ".div")
.replace("parseInt", "new BN");
}, ["Exponentiation"])
},
"MikeMcl bignumber.js": {
url: ["https://rawgit.com/MikeMcl/bignumber.js/master/bignumber.min.js"],
projectURL: "http://mikemcl.github.io/bignumber.js/",
onStart: createInitialization("new BigNumber") + "BigNumber.config({POW_PRECISION: 0});",
tests: generateTests(function (x) {
return x.replace(/\.over/g, ".div")
.replace(/(.+)\.square\(\)/g, "$1.times($1)")
.replace("parseInt", "new BigNumber");
})
},
"Leemon Baird BigInt.js": {
url: ["http://www.leemon.com/crypto/BigInt.js"],
projectURL: "http://www.leemon.com/crypto/BigInt.html",
onStart: createInitialization("str2bigInt", ",10"),
onCycle: createOnCycle(function (v) {
return v + "=" + v + ".concat()";
}),
tests: generateTests(function(x) {
return x.replace(/(\w+)\.add\(([^\)]*)\)/g, "add($1, $2)")
.replace(/(\w+)\.minus\(([^\)]*)\)/g, "sub($1, $2)")
.replace(/(\w+)\.times\(([^\)]*)\)/g, "mult($1, $2)")
.replace(/(\w+)\.over\(([^\)]*)\)/g, "divInt_($1, $2)")
.replace(/(\w+)\.square\(([^\)]*)\)/g, "mult($1, $1)")
.replace("parseInt", "str2bigInt")
.replace(/(\w+)\.toString\(([^\)]*)\)/g, "bigInt2str($1, $2)")
}, ["Exponentiation"])
}
};
return libraries;
})();
var haveScripts = false, timeout;
function getScripts(msg) {
if (haveScripts) return;
importScripts.apply(null, ["benchmark.js"].concat(msg.url));
var start = new Function(msg.onStart);
start();
haveScripts = true;
}
onmessage = function (e) {
var msg = e.data;
getScripts(msg);
if (!msg.testsToRun) {
postMessage({
type: "loaded"
});
return;
}
Benchmark.options.minTime = 1 / 64;
Benchmark.options.maxTime = 1 / 2;
Benchmark.options.minSamples = 5;
var suite = new Benchmark.Suite();
for (var i = 0; i < msg.testsToRun.length; i++) {
var name = msg.testsToRun[i];
suite.add(name, msg.tests[name], {
onCycle: msg.onCycle ? new Function(msg.onCycle) : function () { }
});
}
suite.on("cycle", function (e) {
var target = e.target,
name = target.name,
stats = target.stats,
desc = createDescription(stats);
if (target.aborted) {
if (!stats.mean)
desc = "Test timed out.";
}
postMessage({
type: "cycle",
name: name,
stats: stats,
desc: desc
});
clearTimeout(timeout);
})
.on("complete", function (e) {
postMessage({
type: "complete"
});
}).run({
async: true
});
timeout = setTimeout(function () { // abort tests after 10 seconds
suite.abort();
}, msg.timeout);
};
function createDescription(stats) {
var runs = stats.sample.length;
var rme = stats.rme.toFixed(2);
var mean = 1 / stats.mean || 0;
if (mean >= 100) mean = Math.round(mean) + "";
else if (mean >= 10) mean = mean.toFixed(1);
else if (mean >= 1) mean = mean.toFixed(2);
else mean = mean.toFixed(3);
while (/(\d+)(\d{3})/.test(mean)) {
mean = mean.replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
}
return mean + " ops/sec &pm;" + rme + "% (" + runs + " samples)";
}

Sorry, the diff of this file is not supported yet

var bigInt = (function (undefined) {
"use strict";
var BASE = 1e7,
LOG_BASE = 7,
MAX_INT = 9007199254740992,
MAX_INT_ARR = smallToArray(MAX_INT),
LOG_MAX_INT = Math.log(MAX_INT);
function BigInteger(value, sign) {
this.value = value;
this.sign = sign;
this.isSmall = false;
}
function SmallInteger(value) {
this.value = value;
this.sign = value < 0;
this.isSmall = true;
}
function isPrecise(n) {
return -MAX_INT < n && n < MAX_INT;
}
function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
if (n < 1e7)
return [n];
if (n < 1e14)
return [n % 1e7, Math.floor(n / 1e7)];
return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
}
function arrayToSmall(arr) { // If BASE changes this function may need to change
trim(arr);
var length = arr.length;
if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
switch (length) {
case 0: return 0;
case 1: return arr[0];
case 2: return arr[0] + arr[1] * BASE;
default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
}
}
return arr;
}
function trim(v) {
var i = v.length;
while (v[--i] === 0);
v.length = i + 1;
}
function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
var x = new Array(length);
var i = -1;
while (++i < length) {
x[i] = 0;
}
return x;
}
function truncate(n) {
if (n > 0) return Math.floor(n);
return Math.ceil(n);
}
function add(a, b) { // assumes a and b are arrays with a.length >= b.length
var l_a = a.length,
l_b = b.length,
r = new Array(l_a),
carry = 0,
base = BASE,
sum, i;
for (i = 0; i < l_b; i++) {
sum = a[i] + b[i] + carry;
carry = sum >= base ? 1 : 0;
r[i] = sum - carry * base;
}
while (i < l_a) {
sum = a[i] + carry;
carry = sum === base ? 1 : 0;
r[i++] = sum - carry * base;
}
if (carry > 0) r.push(carry);
return r;
}
function addAny(a, b) {
if (a.length >= b.length) return add(a, b);
return add(b, a);
}
function addSmall(a, carry) { // assumes a is array, carry is number with |carry| + BASE < MAX_INT
var l = a.length,
r = new Array(l),
base = BASE,
sum, i;
for (i = 0; i < l; i++) {
sum = a[i] + carry;
carry = Math.floor(sum / base);
r[i] = sum % base;
}
while (carry > 0) {
r[i++] = carry % base;
carry = Math.floor(carry / base);
}
return r;
}
BigInteger.prototype.add = function (v) {
var value, n = parseValue(v);
if (this.sign !== n.sign) {
return this.subtract(n.negate());
}
var a = this.value, b = n.value;
if (n.isSmall) {
if (isPrecise(b + BASE)) {
return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
}
b = smallToArray(Math.abs(b));
}
return new BigInteger(addAny(a, b), this.sign);
};
BigInteger.prototype.plus = BigInteger.prototype.add;
SmallInteger.prototype.add = function (v) {
var n = parseValue(v);
if (this.sign !== n.sign) {
return this.subtract(n.negate());
}
var a = this.value, b = n.value;
if (n.isSmall) {
if (isPrecise(a + b)) return new SmallInteger(a + b);
b = smallToArray(Math.abs(b));
}
if (isPrecise(a + BASE)) {
return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
}
return new BigInteger(addAny(b, smallToArray(Math.abs(a))), a < 0);
};
SmallInteger.prototype.plus = SmallInteger.prototype.add;
function subtract(a, b) { // assumes a and b are arrays with a >= b
var a_l = a.length,
b_l = b.length,
r = new Array(a_l),
borrow = 0,
base = BASE,
i, difference;
for (i = 0; i < b_l; i++) {
difference = a[i] - borrow - b[i];
if (difference < 0) {
difference += base;
borrow = 1;
} else borrow = 0;
r[i] = difference;
}
for (i = b_l; i < a_l; i++) {
difference = a[i] - borrow;
if (difference < 0) difference += base;
else {
r[i++] = difference;
break;
}
r[i] = difference;
}
for (; i < a_l; i++) {
r[i] = a[i];
}
trim(r);
return r;
}
function subtractAny(a, b, sign) {
var value, isSmall;
if (compareAbs(a, b) >= 0) {
value = subtract(a,b);
} else {
value = subtract(b, a);
sign = !sign;
}
value = arrayToSmall(value);
if (typeof value === "number") {
if (sign) value = -value;
return new SmallInteger(value);
}
return new BigInteger(value, sign);
}
function subtractSmall(a, b, sign) { // assumes a is array, b is number with |b| < MAX_INT
var l = a.length,
r = new Array(l),
carry = -b,
base = BASE,
i, difference;
for (i = 0; i < l; i++) {
difference = a[i] + carry;
carry = Math.floor(difference / base);
r[i] = difference < 0 ? difference % base + base : difference;
}
r = arrayToSmall(r);
if (typeof r === "number") {
if (sign) r = -r;
return new SmallInteger(r);
} return new BigInteger(r, sign);
}
BigInteger.prototype.subtract = function (v) {
var n = parseValue(v);
if (this.sign !== n.sign) {
return this.add(n.negate());
}
var a = this.value, b = n.value;
if (n.isSmall)
return subtractSmall(a, Math.abs(b), this.sign);
return subtractAny(a, b, this.sign);
};
BigInteger.prototype.minus = BigInteger.prototype.subtract;
SmallInteger.prototype.subtract = function (v) {
var n = parseValue(v);
if (this.sign !== n.sign) {
return this.add(n.negate());
}
var a = this.value, b = n.value;
if (n.isSmall) {
return new SmallInteger(a - b);
}
return subtractSmall(b, Math.abs(a), a >= 0);
};
SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
BigInteger.prototype.negate = function () {
return new BigInteger(this.value, !this.sign);
};
SmallInteger.prototype.negate = function () {
var sign = this.sign;
var small = new SmallInteger(-this.value);
small.sign = !sign;
return small;
};
BigInteger.prototype.abs = function () {
return new BigInteger(this.value, false);
};
SmallInteger.prototype.abs = function () {
return new SmallInteger(Math.abs(this.value));
};
function multiplyLong(a, b) {
var a_l = a.length,
b_l = b.length,
l = a_l + b_l,
r = createArray(l),
base = BASE,
product, carry, i, a_i, b_j;
for (i = 0; i < a_l; ++i) {
a_i = a[i];
for (var j = 0; j < b_l; ++j) {
b_j = b[j];
product = a_i * b_j + r[i + j];
carry = Math.floor(product / base);
r[i + j] = product - carry * base;
r[i + j + 1] += carry;
}
}
trim(r);
return r;
}
function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
var l = a.length,
r = new Array(l),
base = BASE,
carry = 0,
product, i;
for (i = 0; i < l; i++) {
product = a[i] * b + carry;
carry = Math.floor(product / base);
r[i] = product - carry * base;
}
while (carry > 0) {
r[i++] = carry % base;
carry = Math.floor(carry / base);
}
return r;
}
function shiftLeft(x, n) {
var r = [];
while (n-- > 0) r.push(0);
return r.concat(x);
}
function multiplyKaratsuba(x, y) {
var n = Math.max(x.length, y.length);
if (n <= 400) return multiplyLong(x, y);
n = Math.ceil(n / 2);
var b = x.slice(n),
a = x.slice(0, n),
d = y.slice(n),
c = y.slice(0, n);
var ac = multiplyKaratsuba(a, c),
bd = multiplyKaratsuba(b, d),
abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
return addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
}
BigInteger.prototype.multiply = function (v) {
var value, n = parseValue(v),
a = this.value, b = n.value,
sign = this.sign !== n.sign,
abs;
if (n.isSmall) {
if (b === 0) return CACHE[0];
if (b === 1) return this;
if (b === -1) return this.negate();
abs = Math.abs(b);
if (abs < BASE) {
return new BigInteger(multiplySmall(a, abs), sign);
}
b = smallToArray(abs);
}
if (a.length + b.length > 4000) // Karatsuba is only faster for sufficiently large inputs
return new BigInteger(multiplyKaratsuba(a, b), sign);
return new BigInteger(multiplyLong(a, b), sign);
};
BigInteger.prototype.times = BigInteger.prototype.multiply;
SmallInteger.prototype.multiply = function (v) {
var n = parseValue(v),
a = this.value,
b = n.value;
if (a === 0) return CACHE[0];
if (a === 1) return n;
if (a === -1) return n.negate();
if (n.isSmall) {
if (isPrecise(a * b)) {
return new SmallInteger(a * b);
}
b = smallToArray(Math.abs(b));
}
var abs = Math.abs(a);
if (abs < BASE) {
return new BigInteger(multiplySmall(b, abs), this.sign !== n.sign);
}
return new BigInteger(multiplyLong(b, smallToArray(abs)), this.sign !== n.sign);
};
SmallInteger.prototype.times = SmallInteger.prototype.multiply;
function square(a) {
var l = a.length,
r = createArray(l + l),
base = BASE,
product, carry, i, a_i, a_j;
for (i = 0; i < l; i++) {
a_i = a[i];
for (var j = 0; j < l; j++) {
a_j = a[j];
product = a_i * a_j + r[i + j];
carry = Math.floor(product / base);
r[i + j] = product - carry * base;
r[i + j + 1] += carry;
}
}
trim(r);
return r;
}
BigInteger.prototype.square = function () {
return new BigInteger(square(this.value), false);
};
SmallInteger.prototype.square = function () {
var value = this.value * this.value;
if (isPrecise(value)) return new SmallInteger(value);
return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
};
function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
var a_l = a.length,
b_l = b.length,
base = BASE,
result = createArray(b.length),
divisorMostSignificantDigit = b[b_l - 1],
// normalization
lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
remainder = multiplySmall(a, lambda),
divisor = multiplySmall(b, lambda),
quotientDigit, shift, carry, borrow, i, l, q;
if (remainder.length <= a_l) remainder.push(0);
if (divisor.length <= b_l) divisor.push(0);
divisorMostSignificantDigit = divisor[b_l - 1];
for (shift = a_l - b_l; shift >= 0; shift--) {
quotientDigit = base - 1;
if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
}
carry = 0;
borrow = 0;
l = divisor.length;
for (i = 0; i < l; i++) {
carry += quotientDigit * divisor[i];
q = Math.floor(carry / base);
borrow += remainder[shift + i] - (carry - q * base);
carry = q;
if (borrow < 0) {
remainder[shift + i] = borrow + base;
borrow = -1;
} else {
remainder[shift + i] = borrow;
borrow = 0;
}
}
while (borrow !== 0) {
quotientDigit -= 1;
carry = 0;
for (i = 0; i < l; i++) {
carry += remainder[shift + i] - base + divisor[i];
if (carry < 0) {
remainder[shift + i] = carry + base;
carry = 0;
} else {
remainder[shift + i] = carry;
carry = 1;
}
}
borrow += carry;
}
result[shift] = quotientDigit;
}
// denormalization
remainder = divModSmall(remainder, lambda)[0];
return [arrayToSmall(result), arrayToSmall(remainder)];
}
function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
// Performs faster than divMod1 on larger input sizes.
var a_l = a.length,
b_l = b.length,
result = [],
part = [],
base = BASE,
guess, xlen, highx, highy, check;
while (a_l) {
part.unshift(a[--a_l]);
if (compareAbs(part, b) < 0) {
result.push(0);
continue;
}
if (part.length === 1 && part[0] === 0) {
guess = 0;
} else {
xlen = part.length;
highx = part[xlen - 1] * base + part[xlen - 2];
highy = b[b_l - 1] * base + b[b_l - 2];
if (xlen > b_l) {
highx = (highx + 1) * base;
}
guess = Math.ceil(highx / highy);
}
do {
check = multiplySmall(b, guess);
if (compareAbs(check, part) <= 0) break;
guess--;
} while (guess);
result.push(guess);
if (!guess) continue;
part = subtract(part, check);
}
result.reverse();
return [arrayToSmall(result), arrayToSmall(part)];
}
function divModSmall(value, lambda) {
var length = value.length,
quotient = createArray(length),
base = BASE,
i, q, remainder, divisor;
remainder = 0;
for (i = length - 1; i >= 0; --i) {
divisor = remainder * base + value[i];
q = truncate(divisor / lambda);
remainder = divisor - q * lambda;
quotient[i] = q | 0;
}
return [quotient, remainder | 0];
}
function divModAny(self, v) {
var value, n = parseValue(v);
var a = self.value, b = n.value;
var quotient;
if (b === 0) throw new Error("Cannot divide by zero");
if (self.isSmall) {
if (n.isSmall) {
return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
}
return [CACHE[0], self];
}
if (n.isSmall) {
if (b === 1) return [self, CACHE[0]];
if (b == -1) return [self.negate(), CACHE[0]];
var abs = Math.abs(b);
if (abs < BASE) {
value = divModSmall(a, abs);
quotient = arrayToSmall(value[0]);
var remainder = value[1];
if (self.sign) remainder = -remainder;
if (typeof quotient === "number") {
if (self.sign !== n.sign) quotient = -quotient;
return [new SmallInteger(quotient), new SmallInteger(remainder)];
}
return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
}
b = smallToArray(abs);
}
var comparison = compareAbs(a, b);
if (comparison === -1) return [CACHE[0], self];
if (comparison === 0) return [CACHE[1], CACHE[0]];
// divMod1 is faster on smaller input sizes
if (a.length + b.length <= 200)
value = divMod1(a, b);
else value = divMod2(a, b);
quotient = value[0];
var qSign = self.sign !== n.sign,
mod = value[1],
mSign = self.sign;
if (typeof quotient === "number") {
if (qSign) quotient = -quotient;
quotient = new SmallInteger(quotient);
} else quotient = new BigInteger(quotient, qSign);
if (typeof mod === "number") {
if (mSign) mod = -mod;
mod = new SmallInteger(mod);
} else mod = new BigInteger(mod, mSign);
return [quotient, mod];
}
BigInteger.prototype.divmod = function (v) {
var result = divModAny(this, v);
return {
quotient: result[0],
remainder: result[1]
};
};
SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
BigInteger.prototype.divide = function (v) {
return divModAny(this, v)[0];
};
SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
BigInteger.prototype.mod = function (v) {
return divModAny(this, v)[1];
};
SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
BigInteger.prototype.pow = function (v) {
var n = parseValue(v),
a = this.value,
b = n.value,
value, x, y;
if (b === 0) return CACHE[1];
if (n.sign) {
if (a === 1) return CACHE[1];
if (a === -1) return isEven(n) ? CACHE[1] : CACHE[-1];
return CACHE[0];
}
if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
if (this.isSmall) {
if (isPrecise(value = Math.pow(a, b)))
return new SmallInteger(truncate(value));
if (a === 0) return CACHE[0];
if (a === 1) return CACHE[1];
}
x = this;
y = CACHE[1];
while (true) {
if (b & 1 === 1) {
y = y.times(x);
--b;
}
if (b === 0) break;
b /= 2;
x = x.square();
}
return y;
};
SmallInteger.prototype.pow = BigInteger.prototype.pow;
BigInteger.prototype.modPow = function (exp, mod) {
exp = parseValue(exp);
mod = parseValue(mod);
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
var r = CACHE[1],
base = this.mod(mod);
if (base.isZero()) return CACHE[0];
while (exp.isPositive()) {
if (exp.isOdd()) r = r.multiply(base).mod(mod);
exp = exp.divide(2);
base = base.square().mod(mod);
}
return r;
};
SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
function compareAbs(a, b) {
if (a.length !== b.length) {
return a.length > b.length ? 1 : -1;
}
for (var i = a.length - 1; i >= 0; i--) {
if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
}
return 0;
}
BigInteger.prototype.compareAbs = function (v) {
var n = parseValue(v),
a = this.value,
b = n.value;
if (n.isSmall) return 1;
return compareAbs(a, b);
};
SmallInteger.prototype.compareAbs = function (v) {
var n = parseValue(v),
a = Math.abs(this.value),
b = n.value;
if (n.isSmall) {
b = Math.abs(b);
return a === b ? 0 : a > b ? 1 : -1;
}
return -1;
};
BigInteger.prototype.compare = function (v) {
var n = parseValue(v),
a = this.value,
b = n.value;
if (this.sign !== n.sign) {
return n.sign ? 1 : -1;
}
if (n.isSmall) {
return this.sign ? -1 : 1;
}
return compareAbs(a, b) * (this.sign ? -1 : 1);
};
BigInteger.prototype.compareTo = BigInteger.prototype.compare;
SmallInteger.prototype.compare = function (v) {
var n = parseValue(v),
a = this.value,
b = n.value;
if (n.isSmall) {
return a == b ? 0 : a > b ? 1 : -1;
}
if (a < 0 !== n.sign) {
return a < 0 ? -1 : 1;
}
return a < 0 ? 1 : -1;
};
SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
BigInteger.prototype.equals = function (v) {
return this.compare(v) === 0;
};
SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
BigInteger.prototype.notEquals = function (v) {
return this.compare(v) !== 0;
};
SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
BigInteger.prototype.greater = function (v) {
return this.compare(v) > 0;
};
SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
BigInteger.prototype.lesser = function (v) {
return this.compare(v) < 0;
};
SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
BigInteger.prototype.greaterOrEquals = function (v) {
return this.compare(v) >= 0;
};
SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
BigInteger.prototype.lesserOrEquals = function (v) {
return this.compare(v) <= 0;
};
SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
BigInteger.prototype.isEven = function () {
return (this.value[0] & 1) === 0;
};
SmallInteger.prototype.isEven = function () {
return (this.value & 1) === 0;
};
BigInteger.prototype.isOdd = function () {
return (this.value[0] & 1) === 1;
};
SmallInteger.prototype.isOdd = function () {
return (this.value & 1) === 1;
};
BigInteger.prototype.isPositive = function () {
return !this.sign;
};
SmallInteger.prototype.isPositive = function () {
return this.value > 0;
};
BigInteger.prototype.isNegative = function () {
return this.sign;
};
SmallInteger.prototype.isNegative = function () {
return this.value < 0;
};
BigInteger.prototype.isUnit = function () {
return false;
};
SmallInteger.prototype.isUnit = function () {
return Math.abs(this.value) === 1;
};
BigInteger.prototype.isZero = function () {
return false;
};
SmallInteger.prototype.isZero = function () {
return this.value === 0;
};
BigInteger.prototype.isDivisibleBy = function (v) {
var n = parseValue(v);
var value = n.value;
if (value === 0) return false;
if (value === 1) return true;
if (value === 2) return this.isEven();
return this.mod(n).equals(CACHE[0]);
};
SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
BigInteger.prototype.isPrime = function () {
var n = this.abs(),
nPrev = n.prev();
if (n.isUnit()) return false;
if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
if (n.lesser(25)) return true;
var a = [2, 3, 5, 7, 11, 13, 17, 19],
b = nPrev,
d, t, i, x;
while (b.isEven()) b = b.divide(2);
for (i = 0; i < a.length; i++) {
x = bigInt(a[i]).modPow(b, n);
if (x.equals(CACHE[1]) || x.equals(nPrev)) continue;
for (t = true, d = b; t && d.lesser(nPrev) ; d = d.multiply(2)) {
x = x.square().mod(n);
if (x.equals(nPrev)) t = false;
}
if (t) return false;
}
return true;
};
SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
BigInteger.prototype.next = function () {
var value = this.value;
if (this.sign) {
return subtractSmall(value, 1, this.sign);
}
return new BigInteger(addSmall(value, 1), this.sign);
};
SmallInteger.prototype.next = function () {
var value = this.value;
if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
return new BigInteger(MAX_INT_ARR, false);
};
BigInteger.prototype.prev = function () {
var value = this.value;
if (this.sign) {
return new BigInteger(addSmall(value, 1), true);
}
return subtractSmall(value, 1, this.sign);
};
SmallInteger.prototype.prev = function () {
var value = this.value;
if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
return new BigInteger(MAX_INT_ARR, true);
};
var powersOfTwo = [1];
while (powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
function shift_isSmall(n) {
return ((typeof n === "number" || typeof n === "string") && +Math.abs(n) <= BASE) ||
(n instanceof BigInteger && n.value.length <= 1);
}
BigInteger.prototype.shiftLeft = function (n) {
if (!shift_isSmall(n)) {
if (n.isNegative()) return this.shiftRight(n.abs());
return this.times(CACHE[2].pow(n));
}
n = +n;
if (n < 0) return this.shiftRight(-n);
var result = this;
while (n >= powers2Length) {
result = result.multiply(highestPower2);
n -= powers2Length - 1;
}
return result.multiply(powersOfTwo[n]);
};
SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
BigInteger.prototype.shiftRight = function (n) {
var remQuo;
if (!shift_isSmall(n)) {
if (n.isNegative()) return this.shiftLeft(n.abs());
remQuo = this.divmod(CACHE[2].pow(n));
return remQuo.remainder.isNegative() ? remQuo.quotient.prev() : remQuo.quotient;
}
n = +n;
if (n < 0) return this.shiftLeft(-n);
var result = this;
while (n >= powers2Length) {
if (result.isZero()) return result;
remQuo = divModAny(result, highestPower2);
result = remQuo[1].isNegative() ? remQuo.quotient.prev() : remQuo[0];
n -= powers2Length - 1;
}
remQuo = divModAny(result, powersOfTwo[n]);
return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
};
SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
function bitwise(x, y, fn) {
y = parseValue(y);
var xSign = x.isNegative(), ySign = y.isNegative();
var xRem = xSign ? x.not() : x,
yRem = ySign ? y.not() : y;
var xBits = [], yBits = [];
var xStop = false, yStop = false;
while (!xStop || !yStop) {
if (xRem.isZero()) { // virtual sign extension for simulating two's complement
xStop = true;
xBits.push(xSign ? 1 : 0);
}
else if (xSign) xBits.push(xRem.isEven() ? 1 : 0); // two's complement for negative numbers
else xBits.push(xRem.isEven() ? 0 : 1);
if (yRem.isZero()) {
yStop = true;
yBits.push(ySign ? 1 : 0);
}
else if (ySign) yBits.push(yRem.isEven() ? 1 : 0);
else yBits.push(yRem.isEven() ? 0 : 1);
xRem = xRem.over(2);
yRem = yRem.over(2);
}
var result = [];
for (var i = 0; i < xBits.length; i++) result.push(fn(xBits[i], yBits[i]));
var sum = bigInt(result.pop()).negate().times(bigInt(2).pow(result.length));
while (result.length) {
sum = sum.add(bigInt(result.pop()).times(bigInt(2).pow(result.length)));
}
return sum;
}
BigInteger.prototype.not = function () {
return this.negate().prev();
};
SmallInteger.prototype.not = BigInteger.prototype.not;
BigInteger.prototype.and = function (n) {
return bitwise(this, n, function (a, b) { return a & b; });
};
SmallInteger.prototype.and = BigInteger.prototype.and;
BigInteger.prototype.or = function (n) {
return bitwise(this, n, function (a, b) { return a | b; });
};
SmallInteger.prototype.or = BigInteger.prototype.or;
BigInteger.prototype.xor = function (n) {
return bitwise(this, n, function (a, b) { return a ^ b; });
};
SmallInteger.prototype.xor = BigInteger.prototype.xor;
function max(a, b) {
a = parseValue(a);
b = parseValue(b);
return a.greater(b) ? a : b;
}
function min(a,b) {
a = parseValue(a);
b = parseValue(b);
return a.lesser(b) ? a : b;
}
function gcd(a, b) {
a = parseValue(a).abs();
b = parseValue(b).abs();
if (a.equals(b)) return a;
if (a.isZero()) return b;
if (b.isZero()) return a;
if (a.isEven()) {
if (b.isOdd()) {
return gcd(a.divide(2), b);
}
return gcd(a.divide(2), b.divide(2)).multiply(2);
}
if (b.isEven()) {
return gcd(a, b.divide(2));
}
if (a.greater(b)) {
return gcd(a.subtract(b).divide(2), b);
}
return gcd(b.subtract(a).divide(2), a);
}
function lcm(a, b) {
a = parseValue(a).abs();
b = parseValue(b).abs();
return a.multiply(b).divide(gcd(a, b));
}
function randBetween(a, b) {
a = parseValue(a);
b = parseValue(b);
if (a.isSmall) a = smallToArray(a);
if (b.isSmall) b = smallToArray(b);
var low = min(a, b), high = max(a, b);
var range = high.subtract(low);
var length = range.value.length - 1;
var result = [], restricted = true;
for (var i = length; i >= 0; i--) {
var top = restricted ? range.value[i] : BASE;
var digit = truncate(Math.random() * top);
result.unshift(digit);
if (digit < top) restricted = false;
}
result = arrayToSmall(result);
return low.add(new BigInteger(result, false, typeof result === "number"));
}
var parseBase = function (text, base) {
var val = CACHE[0], pow = CACHE[1],
length = text.length;
if (2 <= base && base <= 36) {
if (length <= LOG_MAX_INT / Math.log(base)) {
return new SmallInteger(parseInt(text, base));
}
}
base = parseValue(base);
var digits = [];
var i;
var isNegative = text[0] === "-";
for (i = isNegative ? 1 : 0; i < text.length; i++) {
var c = text[i].toLowerCase(),
charCode = c.charCodeAt(0);
if (48 <= charCode && charCode <= 57) digits.push(parseValue(c));
else if (97 <= charCode && charCode <= 122) digits.push(parseValue(c.charCodeAt(0) - 87));
else if (c === "<") {
var start = i;
do { i++; } while (text[i] !== ">");
digits.push(parseValue(text.slice(start + 1, i)));
}
else throw new Error(c + " is not a valid character");
}
digits.reverse();
for (i = 0; i < digits.length; i++) {
val = val.add(digits[i].times(pow));
pow = pow.times(base);
}
return isNegative ? val.negate() : val;
};
function stringify(digit) {
var v = digit.value;
if (typeof v === "number") v = [v];
if (v.length === 1 && v[0] <= 36) {
return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0]);
}
return "<" + v + ">";
}
function toBase(n, base) {
base = bigInt(base);
if (base.isZero()) {
if (n.isZero()) return "0";
throw new Error("Cannot convert nonzero numbers to base 0.");
}
if (base.equals(-1)) {
if (n.isZero()) return "0";
if (n.isNegative()) return new Array(1 - n).join("10");
return "1" + new Array(+n).join("01");
}
var minusSign = "";
if (n.isNegative() && base.isPositive()) {
minusSign = "-";
n = n.abs();
}
if (base.equals(1)) {
if (n.isZero()) return "0";
return minusSign + new Array(+n + 1).join(1);
}
var out = [];
var left = n, divmod;
while (left.isNegative() || left.compareAbs(base) >= 0) {
divmod = left.divmod(base);
left = divmod.quotient;
var digit = divmod.remainder;
if (digit.isNegative()) {
digit = base.minus(digit).abs();
left = left.next();
}
out.push(stringify(digit));
}
out.push(stringify(left));
return minusSign + out.reverse().join("");
}
BigInteger.prototype.toString = function (radix) {
if (radix === undefined) radix = 10;
if (radix !== 10) return toBase(this, radix);
var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
while (--l >= 0) {
digit = String(v[l]);
str += zeros.slice(digit.length) + digit;
}
var sign = this.sign ? "-" : "";
return sign + str;
};
SmallInteger.prototype.toString = function (radix) {
if (radix === undefined) radix = 10;
if (radix != 10) return toBase(this, radix);
return String(this.value);
};
BigInteger.prototype.valueOf = function () {
if (this.isSmall) return this.value;
return +this.toString();
};
BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
function parseValue(v) {
if (v instanceof BigInteger || v instanceof SmallInteger) return v;
if (typeof v === "number") {
if (isPrecise(v)) return new SmallInteger(v);
v = String(v);
}
if (typeof v === "string") {
if (isPrecise(+v)) {
var x = +v;
if (x === truncate(x))
return new SmallInteger(x);
throw "Invalid integer: " + v;
}
var sign = v[0] === "-";
if (sign) v = v.slice(1);
var split = v.split(/e/i);
if (split.length > 2) throw new Error("Invalid integer: " + text.join("e"));
if (split.length === 2) {
var exp = split[1];
if (exp[0] === "+") exp = exp.slice(1);
exp = +exp;
if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
var text = split[0];
var decimalPlace = text.indexOf(".");
if (decimalPlace >= 0) {
exp -= text.length - decimalPlace;
text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
}
if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
text += (new Array(exp + 1)).join("0");
v = text;
}
var isValid = /^([0-9][0-9]*)$/.test(v);
if (!isValid) throw new Error("Invalid integer: " + v);
var r = [], max = v.length, l = LOG_BASE, min = max - l;
while (max > 0) {
r.push(+v.slice(min, max));
min -= l;
if (min < 0) min = 0;
max -= l;
}
trim(r);
return new BigInteger(r, sign);
}
}
// Pre-define numbers in range [-999,999]
var CACHE = function (v, radix) {
if (typeof v === "undefined") return CACHE[0];
if (typeof radix !== "undefined") return +radix === 10 ? parseValue(v) : parseBase(v, radix);
return parseValue(v);
};
for (var i = 0; i < 1000; i++) {
CACHE[i] = new SmallInteger(i);
if (i > 0) CACHE[-i] = new SmallInteger(-i);
}
// Backwards compatibility
CACHE.one = CACHE[1];
CACHE.zero = CACHE[0];
CACHE.minusOne = CACHE[-1];
CACHE.max = max;
CACHE.min = min;
CACHE.gcd = gcd;
CACHE.lcm = lcm;
CACHE.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger; };
CACHE.randBetween = randBetween;
return CACHE;
})();
// Node.js check
if (typeof module !== "undefined") {
module.exports = bigInt;
}
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
{
"name": "big-integer",
"version": "1.4.11",
"author": "Peter Olson <peter.e.c.olson+npm@gmail.com>",
"description": "An arbitrary length integer library for Javascript",
"contributors": [],
"bin": {},
"scripts": {
"test": "./node_modules/.bin/jasmine"
},
"main": "./BigInteger",
"repository": {
"type": "git",
"url": "git@github.com:peterolson/BigInteger.js.git"
},
"keywords": [
"math",
"big",
"bignum",
"bigint",
"biginteger",
"integer",
"arbitrary",
"precision",
"arithmetic"
],
"devDependencies" : {
"jasmine": "2.1.x"
},
"license": "WTFPL",
"engines": {
"node": ">=0.6"
}
}
[![Build Status](https://travis-ci.org/peterolson/BigInteger.js.svg?branch=master)](https://travis-ci.org/peterolson/BigInteger.js)
BigInteger.js
=========
**BigInteger.js** is an arbitrary-length integer library for Javascript, allowing arithmetic operations on integers of unlimited size, notwithstanding memory and time limitations.
If you are using a browser, you can download [BigInteger.js from GitHub](http://peterolson.github.com/BigInteger.js/BigInteger.min.js) or just hotlink to it:
<script src="http://peterolson.github.com/BigInteger.js/BigInteger.min.js"></script>
If you are using node, you can install BigInteger with [npm](https://npmjs.org/).
npm install big-integer
Then you can include it in your code:
var bigInt = require("big-integer");
The unit tests are contained in the `spec/spec.js` file. You can [run them online from GitHub](http://peterolson.github.io/BigInteger.js/spec/SpecRunner.html).
There are performance benchmarks that can be viewed from the `benchmarks/index.html` page. You can [run them online from GitHub](http://peterolson.github.io/BigInteger.js/benchmark/).
`bigInt(number, [base])`
---
You can create a bigInt by calling the `bigInt` function. You can pass in
- a string, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
- a Javascript number, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
- another bigInt.
- nothing, and it will return `bigInt.zero`.
If you provide a second parameter, then it will parse `number` as a number in base `base`. Note that `base` can be any bigInt (even negative or zero). The letters "a-z" and "A-Z" will be interpreted as the numbers 10 to 36. Higher digits can be specified in angle brackets (`<` and `>`).
Examples:
var zero = bigInt();
var ninetyThree = bigInt(93);
var largeNumber = bigInt("75643564363473453456342378564387956906736546456235345");
var googol = bigInt("1e100");
var bigNumber = bigInt(largeNumber);
var maximumByte = bigInt("FF", 16);
var fiftyFiveGoogol = bigInt("<55>0", googol);
Note that Javascript numbers larger than `9007199254740992` and smaller than `-9007199254740992` are not precisely represented numbers and will not produce exact results. If you are dealing with numbers outside that range, it is better to pass in strings.
Method Chaining
---
Note that bigInt operations return bigInts, which allows you to chain methods, for example:
var salary = bigInt(dollarsPerHour).times(hoursWorked).plus(randomBonuses)
Constants
---
There are three named constants already stored that you do not have to construct with the `bigInt` function yourself:
- `bigInt.one`, equivalent to `bigInt(1)`
- `bigInt.zero`, equivalent to `bigInt(0)`
- `bigInt.minusOne`, equivalent to `bigInt(-1)`
The numbers from -999 to 999 are also already prestored and can be accessed using `bigInt[index]`, for example:
- `bigInt[-999]`, equivalent to `bigInt(-999)`
- `bigInt[256]`, equivalent to `bigInt(256)`
Methods
===
`abs()`
---
Returns the absolute value of a bigInt.
- `bigInt(-45).abs()` => `45`
- `bigInt(45).abs()` => `45`
`add(number)`
---
Performs addition.
- `bigInt(5).add(7)` => `12`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
`and(number)`
---
Performs the bitwise AND operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(6).and(3)` => `2`
- `bigInt(6).and(-3)` => `4`
`compare(number)`
---
Performs a comparison between two numbers. If the numbers are equal, it returns `0`. If the first number is greater, it returns `1`. If the first number is lesser, it returns `-1`.
- `bigInt(5).compare(5)` => `0`
- `bigInt(5).compare(4)` => `1`
- `bigInt(4).compare(5)` => `-1`
`compareAbs(number)`
---
Performs a comparison between the absolute value of two numbers.
- `bigInt(5).compareAbs(-5)` => `0`
- `bigInt(5).compareAbs(4)` => `1`
- `bigInt(4).compareAbs(-5)` => `-1`
`compareTo(number)`
---
Alias for the `compare` method.
`divide(number)`
---
Performs integer division, disregarding the remainder.
- `bigInt(59).divide(5)` => `11`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
`divmod(number)`
---
Performs division and returns an object with two properties: `quotient` and `remainder`. The sign of the remainder will match the sign of the dividend.
- `bigInt(59).divmod(5)` => `{quotient: bigInt(11), remainder: bigInt(4) }`
- `bigInt(-5).divmod(2)` => `{quotient: bigInt(-2), remainder: bigInt(-1) }`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
`eq(number)`
---
Alias for the `equals` method.
`equals(number)`
---
Checks if two numbers are equal.
- `bigInt(5).equals(5)` => `true`
- `bigInt(4).equals(7)` => `false`
`geq(number)`
---
Alias for the `greaterOrEquals` method.
`greater(number)`
---
Checks if the first number is greater than the second.
- `bigInt(5).greater(6)` => `false`
- `bigInt(5).greater(5)` => `false`
- `bigInt(5).greater(4)` => `true`
`greaterOrEquals(number)`
---
Checks if the first number is greater than or equal to the second.
- `bigInt(5).greaterOrEquals(6)` => `false`
- `bigInt(5).greaterOrEquals(5)` => `true`
- `bigInt(5).greaterOrEquals(4)` => `true`
`gt(number)`
---
Alias for the `greater` method.
`isDivisibleBy(number)`
---
Returns `true` if the first number is divisible by the second number, `false` otherwise.
- `bigInt(999).isDivisibleBy(333)` => `true`
- `bigInt(99).isDivisibleBy(5)` => `false`
`isEven()`
---
Returns `true` if the number is even, `false` otherwise.
- `bigInt(6).isEven()` => `true`
- `bigInt(3).isEven()` => `false`
`isNegative()`
---
Returns `true` if the number is negative, `false` otherwise.
Returns `false` for `0` and `-0`.
- `bigInt(-23).isNegative()` => `true`
- `bigInt(50).isNegative()` => `false`
`isOdd()`
---
Returns `true` if the number is odd, `false` otherwise.
- `bigInt(13).isOdd()` => `true`
- `bigInt(40).isOdd()` => `false`
`isPrime()`
---
Returns `true` if the number is prime, `false` otherwise.
- `bigInt(5).isPrime()` => `true`
- `bigInt(6).isPrime()` => `false`
`isPositive()`
---
Return `true` if the number is positive, `false` otherwise.
Returns `false` for `0` and `-0`.
- `bigInt(54).isPositive()` => `true`
- `bigInt(-1).isPositive()` => `false`
`isUnit()`
---
Returns `true` if the number is `1` or `-1`, `false` otherwise.
- `bigInt.one.isUnit()` => `true`
- `bigInt.minusOne.isUnit()` => `true`
- `bigInt(5).isUnit()` => `false`
`isZero()`
---
Return `true` if the number is `0` or `-0`, `false` otherwise.
- `bigInt.zero.isZero()` => `true`
- `bigInt("-0").isZero()` => `true`
- `bigInt(50).isZero()` => `false`
`leq(number)`
---
Alias for the `lesserOrEquals` method.
`lesser(number)`
---
Checks if the first number is lesser than the second.
- `bigInt(5).lesser(6)` => `true`
- `bigInt(5).lesser(5)` => `false`
- `bigInt(5).lesser(4)` => `false`
`lesserOrEquals(number)`
---
Checks if the first number is less than or equal to the second.
- `bigInt(5).lesserOrEquals(6)` => `true`
- `bigInt(5).lesserOrEquals(5)` => `true`
- `bigInt(5).lesserOrEquals(4)` => `false`
`lt(number)`
---
Alias for the `lesser` method.
`minus(number)`
---
Alias for the `subtract` method.
- `bigInt(3).minus(5)` => `-2`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
`mod(number)`
---
Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend.
- `bigInt(59).mod(5)` => `4`
- `bigInt(-5).mod(2)` => `-1`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
`modPow(exp, mod)`
---
Takes the number to the power `exp` modulo `mod`.
- `bigInt(10).modPow(3, 30)` => `10`
`multiply(number)`
---
Performs multiplication.
- `bigInt(111).multiply(111)` => `12321`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
`neq(number)`
---
Alias for the `notEquals` method.
`next()`
---
Adds one to the number.
- `bigInt(6).next()` => `7`
`not()`
---
Performs the bitwise NOT operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(10).not()` => `-5`
- `bigInt(0).not()` => `-1`
`notEquals(number)`
---
Checks if two numbers are not equal.
- `bigInt(5).notEquals(5)` => `false`
- `bigInt(4).notEquals(7)` => `true`
- `bigInt(6).next()` => `7`
`or(number)`
---
Performs the bitwise OR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(13).or(10)` => `15`
- `bigInt(13).or(-8)` => `-3`
`over(number)`
---
Alias for the `divide` method.
- `bigInt(59).over(5)` => `11`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
`plus(number)`
---
Alias for the `add` method.
- `bigInt(5).plus(7)` => `12`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
`pow(number)`
---
Performs exponentiation. If the exponent is less than `0`, `pow` returns `0`. `bigInt.zero.pow(0)` returns `1`.
- `bigInt(16).pow(16)` => `18446744073709551616`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Exponentiation)
`prev(number)`
---
Subtracts one from the number.
- `bigInt(6).prev()` => `5`
`remainder(number)`
---
Alias for the `mod` method.
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
`shiftLeft(n)`
---
Shifts the number left by `n` places in its binary representation. If a negative number is provided, it will shift right.
- `bigInt(8).shiftLeft(2)` => `32`
- `bigInt(8).shiftLeft(-2)` => `2`
`shiftRight(n)`
---
Shifts the number right by `n` places in its binary representation. If a negative number is provided, it will shift left.
- `bigInt(8).shiftRight(2)` => `2`
- `bigInt(8).shiftRight(-2)` => `32`
`square()`
---
Squares the number
- `bigInt(3).square()` => `9`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Squaring)
`subtract(number)`
---
Performs subtraction.
- `bigInt(3).subtract(5)` => `-2`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
`times(number)`
---
Alias for the `multiply` method.
- `bigInt(111).times(111)` => `12321`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
`toJSNumber()`
---
Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range `[-9007199254740992, 9007199254740992]`.
- `bigInt("18446744073709551616").toJSNumber()` => `18446744073709552000`
`xor(number)`
---
Performs the bitwise XOR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(12).xor(5)` => `9`
- `bigInt(12).xor(-5)` => `-9`
Static Methods
===
`gcd(a, b)`
---
Finds the greatest common denominator of `a` and `b`.
- `bigInt.gcd(42,56)` => `14`
`isInstance(x)`
---
Returns `true` if `x` is a BigInteger, `false` otherwise.
- `bigInt.isInstance(bigInt(14))` => `true`
- `bigInt.isInstance(14)` => `false`
`lcm(a,b)`
---
Finds the least common multiple of `a` and `b`.
- `bigInt.lcm(21, 6)` => `42`
`max(a,b)`
---
Returns the largest of `a` and `b`.
- `bigInt.max(77, 432)` => `432`
`min(a,b)`
---
Returns the smallest of `a` and `b`.
- `bigInt.min(77, 432)` => `77`
`randBetween(min, max)`
---
Returns a random number between `min` and `max`.
- `bigInt.randBetween("-1e100", "1e100")` => (for example) `8494907165436643479673097939554427056789510374838494147955756275846226209006506706784609314471378745`
Override Methods
===
`toString(radix = 10)`
---
Converts a bigInt to a string. There is an optional radix parameter (which defaults to 10) that converts the number to the given radix. Digits in the range `10-36` will use the letters `a-z`.
- `bigInt("1e9").toString()` => `"1000000000"`
- `bigInt("1e9").toString(16)` => `"3b9aca00"`
**Note that arithmetical operators will trigger the `valueOf` function rather than the `toString` function.** When converting a bigInteger to a string, you should use the `toString` method or the `String` function instead of adding the empty string.
- `bigInt("999999999999999999").toString()` => `"999999999999999999"`
- `String(bigInt("999999999999999999"))` => `"999999999999999999"`
- `bigInt("999999999999999999") + ""` => `1000000000000000000`
Bases larger than 36 are supported. If a digit is larger than 36, it will be enclosed in angle brackets.
- `bigInt(567890).toString(100)` => `"<56><78><90>"`
Negative bases are also supported.
- `bigInt(12345).toString(-10)` => `"28465"`
Base 1 and base -1 are also supported.
- `bigInt(-15).toString(1)` => `"-111111111111111"`
- `bigInt(-15).toString(-1)` => `"101010101010101010101010101010"`
Base 0 is only allowed for the number zero.
- `bigInt(0).toString(0)` => `0`
- `bigInt(1).toString(0)` => `Error: Cannot convert nonzero numbers to base 0.`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#toString)
`valueOf()`
---
Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion:
- `bigInt("100") + bigInt("200") === 300; //true`
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
(function() {
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
window.jasmine = jasmineRequire.core(jasmineRequire);
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
if (typeof window == "undefined" && typeof exports == "object") {
extend(exports, jasmineInterface);
} else {
extend(window, jasmineInterface);
}
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
var catchingExceptions = queryString.getParam("catch");
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
timer: new jasmine.Timer()
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
env.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());
/*
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function getJasmineRequireObj() {
if (typeof module !== 'undefined' && module.exports) {
return exports;
} else {
window.jasmineRequire = window.jasmineRequire || {};
return window.jasmineRequire;
}
}
getJasmineRequireObj().console = function(jRequire, j$) {
j$.ConsoleReporter = jRequire.ConsoleReporter();
};
getJasmineRequireObj().ConsoleReporter = function() {
var noopTimer = {
start: function(){},
elapsed: function(){ return 0; }
};
function ConsoleReporter(options) {
var print = options.print,
showColors = options.showColors || false,
onComplete = options.onComplete || function() {},
timer = options.timer || noopTimer,
specCount,
failureCount,
failedSpecs = [],
pendingCount,
ansi = {
green: '\x1B[32m',
red: '\x1B[31m',
yellow: '\x1B[33m',
none: '\x1B[0m'
},
failedSuites = [];
print('ConsoleReporter is deprecated and will be removed in a future version.');
this.jasmineStarted = function() {
specCount = 0;
failureCount = 0;
pendingCount = 0;
print('Started');
printNewline();
timer.start();
};
this.jasmineDone = function() {
printNewline();
for (var i = 0; i < failedSpecs.length; i++) {
specFailureDetails(failedSpecs[i]);
}
if(specCount > 0) {
printNewline();
var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
failureCount + ' ' + plural('failure', failureCount);
if (pendingCount) {
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
}
print(specCounts);
} else {
print('No specs found');
}
printNewline();
var seconds = timer.elapsed() / 1000;
print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline();
for(i = 0; i < failedSuites.length; i++) {
suiteFailureDetails(failedSuites[i]);
}
onComplete(failureCount === 0);
};
this.specDone = function(result) {
specCount++;
if (result.status == 'pending') {
pendingCount++;
print(colored('yellow', '*'));
return;
}
if (result.status == 'passed') {
print(colored('green', '.'));
return;
}
if (result.status == 'failed') {
failureCount++;
failedSpecs.push(result);
print(colored('red', 'F'));
}
};
this.suiteDone = function(result) {
if (result.failedExpectations && result.failedExpectations.length > 0) {
failureCount++;
failedSuites.push(result);
}
};
return this;
function printNewline() {
print('\n');
}
function colored(color, str) {
return showColors ? (ansi[color] + str + ansi.none) : str;
}
function plural(str, count) {
return count == 1 ? str : str + 's';
}
function repeat(thing, times) {
var arr = [];
for (var i = 0; i < times; i++) {
arr.push(thing);
}
return arr;
}
function indent(str, spaces) {
var lines = (str || '').split('\n');
var newArr = [];
for (var i = 0; i < lines.length; i++) {
newArr.push(repeat(' ', spaces).join('') + lines[i]);
}
return newArr.join('\n');
}
function specFailureDetails(result) {
printNewline();
print(result.fullName);
for (var i = 0; i < result.failedExpectations.length; i++) {
var failedExpectation = result.failedExpectations[i];
printNewline();
print(indent(failedExpectation.message, 2));
print(indent(failedExpectation.stack, 2));
}
printNewline();
}
function suiteFailureDetails(result) {
for (var i = 0; i < result.failedExpectations.length; i++) {
printNewline();
print(colored('red', 'An error was thrown in an afterAll'));
printNewline();
print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
}
printNewline();
}
}
return ConsoleReporter;
};

Sorry, the diff of this file is not supported yet

/*
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
jasmineRequire.html = function(j$) {
j$.ResultsNode = jasmineRequire.ResultsNode();
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
};
jasmineRequire.HtmlReporter = function(j$) {
var noopTimer = {
start: function() {},
elapsed: function() { return 0; }
};
function HtmlReporter(options) {
var env = options.env || {},
getContainer = options.getContainer,
createElement = options.createElement,
createTextNode = options.createTextNode,
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
timer = options.timer || noopTimer,
results = [],
specsExecuted = 0,
failureCount = 0,
pendingSpecCount = 0,
htmlReporterMain,
symbols,
failedSuites = [];
this.initialize = function() {
clearPrior();
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
createDom('div', {className: 'banner'},
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'version'}, j$.version)
),
createDom('ul', {className: 'symbol-summary'}),
createDom('div', {className: 'alert'}),
createDom('div', {className: 'results'},
createDom('div', {className: 'failures'})
)
);
getContainer().appendChild(htmlReporterMain);
symbols = find('.symbol-summary');
};
var totalSpecsDefined;
this.jasmineStarted = function(options) {
totalSpecsDefined = options.totalSpecsDefined || 0;
timer.start();
};
var summary = createDom('div', {className: 'summary'});
var topResults = new j$.ResultsNode({}, '', null),
currentParent = topResults;
this.suiteStarted = function(result) {
currentParent.addChild(result, 'suite');
currentParent = currentParent.last();
};
this.suiteDone = function(result) {
if (result.status == 'failed') {
failedSuites.push(result);
}
if (currentParent == topResults) {
return;
}
currentParent = currentParent.parent;
};
this.specStarted = function(result) {
currentParent.addChild(result, 'spec');
};
var failures = [];
this.specDone = function(result) {
if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
console.error('Spec \'' + result.fullName + '\' has no expectations.');
}
if (result.status != 'disabled') {
specsExecuted++;
}
symbols.appendChild(createDom('li', {
className: noExpectations(result) ? 'empty' : result.status,
id: 'spec_' + result.id,
title: result.fullName
}
));
if (result.status == 'failed') {
failureCount++;
var failure =
createDom('div', {className: 'spec-detail failed'},
createDom('div', {className: 'description'},
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
),
createDom('div', {className: 'messages'})
);
var messages = failure.childNodes[1];
for (var i = 0; i < result.failedExpectations.length; i++) {
var expectation = result.failedExpectations[i];
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
}
failures.push(failure);
}
if (result.status == 'pending') {
pendingSpecCount++;
}
};
this.jasmineDone = function() {
var banner = find('.banner');
banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
var alert = find('.alert');
alert.appendChild(createDom('span', { className: 'exceptions' },
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
createDom('input', {
className: 'raise',
id: 'raise-exceptions',
type: 'checkbox'
})
));
var checkbox = find('#raise-exceptions');
checkbox.checked = !env.catchingExceptions();
checkbox.onclick = onRaiseExceptionsClick;
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
alert.appendChild(
createDom('span', {className: 'bar skipped'},
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
)
);
}
var statusBarMessage = '';
var statusBarClassName = 'bar ';
if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
} else {
statusBarClassName += 'skipped';
statusBarMessage += 'No specs found';
}
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
for(i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
var errorBarClassName = 'bar errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}
}
var results = find('.results');
results.appendChild(summary);
summaryList(topResults, summary);
function summaryList(resultsTree, domParent) {
var specListNode;
for (var i = 0; i < resultsTree.children.length; i++) {
var resultNode = resultsTree.children[i];
if (resultNode.type == 'suite') {
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'suite-detail'},
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
)
);
summaryList(resultNode, suiteListNode);
domParent.appendChild(suiteListNode);
}
if (resultNode.type == 'spec') {
if (domParent.getAttribute('class') != 'specs') {
specListNode = createDom('ul', {className: 'specs'});
domParent.appendChild(specListNode);
}
var specDescription = resultNode.result.description;
if(noExpectations(resultNode.result)) {
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
}
specListNode.appendChild(
createDom('li', {
className: resultNode.result.status,
id: 'spec-' + resultNode.result.id
},
createDom('a', {href: specHref(resultNode.result)}, specDescription)
)
);
}
}
}
if (failures.length) {
alert.appendChild(
createDom('span', {className: 'menu bar spec-list'},
createDom('span', {}, 'Spec List | '),
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
alert.appendChild(
createDom('span', {className: 'menu bar failure-list'},
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {}, ' | Failures ')));
find('.failures-menu').onclick = function() {
setMenuModeTo('failure-list');
};
find('.spec-list-menu').onclick = function() {
setMenuModeTo('spec-list');
};
setMenuModeTo('failure-list');
var failureNode = find('.failures');
for (var i = 0; i < failures.length; i++) {
failureNode.appendChild(failures[i]);
}
}
};
return this;
function find(selector) {
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
}
function clearPrior() {
// return the reporter
var oldReporter = find('');
if(oldReporter) {
getContainer().removeChild(oldReporter);
}
}
function createDom(type, attrs, childrenVarArgs) {
var el = createElement(type);
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child === 'string') {
el.appendChild(createTextNode(child));
} else {
if (child) {
el.appendChild(child);
}
}
}
for (var attr in attrs) {
if (attr == 'className') {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
}
return el;
}
function pluralize(singular, count) {
var word = (count == 1 ? singular : singular + 's');
return '' + count + ' ' + word;
}
function specHref(result) {
return '?spec=' + encodeURIComponent(result.fullName);
}
function setMenuModeTo(mode) {
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
}
function noExpectations(result) {
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
result.status === 'passed';
}
}
return HtmlReporter;
};
jasmineRequire.HtmlSpecFilter = function() {
function HtmlSpecFilter(options) {
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var filterPattern = new RegExp(filterString);
this.matches = function(specName) {
return filterPattern.test(specName);
};
}
return HtmlSpecFilter;
};
jasmineRequire.ResultsNode = function() {
function ResultsNode(result, type, parent) {
this.result = result;
this.type = type;
this.parent = parent;
this.children = [];
this.addChild = function(result, type) {
this.children.push(new ResultsNode(result, type, this));
};
this.last = function() {
return this.children[this.children.length - 1];
};
}
return ResultsNode;
};
jasmineRequire.QueryString = function() {
function QueryString(options) {
this.setParam = function(key, value) {
var paramMap = queryStringToParamMap();
paramMap[key] = value;
options.getWindowLocation().search = toQueryString(paramMap);
};
this.getParam = function(key) {
return queryStringToParamMap()[key];
};
return this;
function toQueryString(paramMap) {
var qStrPairs = [];
for (var prop in paramMap) {
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
}
return '?' + qStrPairs.join('&');
}
function queryStringToParamMap() {
var paramStr = options.getWindowLocation().search.substring(1),
params = [],
paramMap = {};
if (paramStr.length > 0) {
params = paramStr.split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
var value = decodeURIComponent(p[1]);
if (value === 'true' || value === 'false') {
value = JSON.parse(value);
}
paramMap[decodeURIComponent(p[0])] = value;
}
}
return paramMap;
}
}
return QueryString;
};
body { overflow-y: scroll; }
.jasmine_html-reporter { background-color: #eeeeee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
.jasmine_html-reporter a { text-decoration: none; }
.jasmine_html-reporter a:hover { text-decoration: underline; }
.jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; }
.jasmine_html-reporter .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
.jasmine_html-reporter .banner { position: relative; }
.jasmine_html-reporter .banner .title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4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A3LjQ2NSw5MDMuNDQ1IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTIiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjxwYXRoCiAgICAgICAgICAgICBkPSJtIDM4MC42ODgsNjIyLjEyOSAtMTEuNjI2LDM1LjgwMSAxNzUuNzU4LDU3LjA5IDExLjYyMSwtMzUuODAxIC0xNzUuNzUzLC01Ny4wOSIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICAgICAgICBpZD0icGF0aDU0IgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzhhNDE4MjtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6bm9uemVybztzdHJva2U6bm9uZSIgLz48cGF0aAogICAgICAgICAgICAgZD0ibSA3MTYuMjg5LDM3Ni41OSAzNy42NDA2LDAgMCwxODQuODE2IC0zNy42NDA2LDAgMCwtMTg0LjgxNiB6IgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=') no-repeat, none; -webkit-background-size: 100%; -moz-background-size: 100%; -o-background-size: 100%; background-size: 100%; display: block; float: left; width: 90px; height: 25px; }
.jasmine_html-reporter .banner .version { margin-left: 14px; position: relative; top: 6px; }
.jasmine_html-reporter .banner .duration { position: absolute; right: 14px; top: 6px; }
.jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; }
.jasmine_html-reporter .version { color: #aaaaaa; }
.jasmine_html-reporter .banner { margin-top: 14px; }
.jasmine_html-reporter .duration { color: #aaaaaa; float: right; }
.jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
.jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; }
.jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; }
.jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; }
.jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; }
.jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
.jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; }
.jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
.jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; }
.jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
.jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; }
.jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; }
.jasmine_html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
.jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
.jasmine_html-reporter .bar.failed { background-color: #ca3a11; }
.jasmine_html-reporter .bar.passed { background-color: #007069; }
.jasmine_html-reporter .bar.skipped { background-color: #bababa; }
.jasmine_html-reporter .bar.errored { background-color: #ca3a11; }
.jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaaaaa; }
.jasmine_html-reporter .bar.menu a { color: #333333; }
.jasmine_html-reporter .bar a { color: white; }
.jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; }
.jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; }
.jasmine_html-reporter .running-alert { background-color: #666666; }
.jasmine_html-reporter .results { margin-top: 14px; }
.jasmine_html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
.jasmine_html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
.jasmine_html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
.jasmine_html-reporter.showDetails .summary { display: none; }
.jasmine_html-reporter.showDetails #details { display: block; }
.jasmine_html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
.jasmine_html-reporter .summary { margin-top: 14px; }
.jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
.jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
.jasmine_html-reporter .summary li.passed a { color: #007069; }
.jasmine_html-reporter .summary li.failed a { color: #ca3a11; }
.jasmine_html-reporter .summary li.empty a { color: #ba9d37; }
.jasmine_html-reporter .summary li.pending a { color: #ba9d37; }
.jasmine_html-reporter .description + .suite { margin-top: 0; }
.jasmine_html-reporter .suite { margin-top: 14px; }
.jasmine_html-reporter .suite a { color: #333333; }
.jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; }
.jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; }
.jasmine_html-reporter .failures .spec-detail .description a { color: white; }
.jasmine_html-reporter .result-message { padding-top: 14px; color: #333333; white-space: pre; }
.jasmine_html-reporter .result-message span.result { display: block; }
.jasmine_html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>BigInteger Tests</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.1.3/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.1.3/jasmine.css">
<script src="lib/jasmine-2.1.3/jasmine.js"></script>
<script src="lib/jasmine-2.1.3/jasmine-html.js"></script>
<script src="lib/jasmine-2.1.3/boot.js"></script>
<!-- include source files here... -->
<script src="../BigInteger.js"></script>
<!-- include spec files here... -->
<script src="spec.js"></script>
</head>
<body>
</body>
</html>
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
]
}
+1
-1

@@ -1,1 +0,1 @@

var bigInt=function(){var e=1e7,t=7,n={positive:!1,negative:!0},r=function(e,t){var n=e.value,r=t.value,i=n.length>r.length?n.length:r.length;for(var s=0;s<i;s++)n[s]=n[s]||0,r[s]=r[s]||0;for(var s=i-1;s>=0;s--){if(n[s]!==0||r[s]!==0)break;n.pop(),r.pop()}n.length||(n=[0],r=[0]),e.value=n,t.value=r},i=function(e,s){if(typeof e=="object")return e;e+="";var u=n.positive,a=[];e[0]==="-"&&(u=n.negative,e=e.slice(1));var e=e.split("e");if(e.length>2)throw new Error("Invalid integer");if(e[1]){var f=e[1];f[0]==="+"&&(f=f.slice(1)),f=i(f);if(f.lesser(0))throw new Error("Cannot include negative exponent part for integers");while(f.notEquals(0))e[0]+="0",f=f.prev()}e=e[0],e==="-0"&&(e="0");var l=/^([0-9][0-9]*)$/.test(e);if(!l)throw new Error("Invalid integer");while(e.length){var c=e.length>t?e.length-t:0;a.push(+e.slice(c)),e=e.slice(0,c)}var h=o(a,u);return s&&r(s,h),h},s=function(e,t){var e=o(e,n.positive),t=o(t,n.positive);if(e.equals(0))throw new Error("Cannot divide by 0");var r=0;do{var i=1,s=o(e.value,n.positive),u=s.times(10);while(u.lesser(t))s=u,i*=10,u=u.times(10);while(s.lesserOrEquals(t))t=t.minus(s),r+=i}while(e.lesserOrEquals(t));return{remainder:t.value,result:r}},o=function(f,l){var c={value:f,sign:l},h={value:f,sign:l,negate:function(e){var t=e||c;return o(t.value,!t.sign)},abs:function(e){var t=e||c;return o(t.value,n.positive)},add:function(t,s){var u,a=c,f;s?(a=i(t))&&(f=i(s)):f=i(t,a),u=a.sign;if(a.sign!==f.sign)return a=o(a.value,n.positive),f=o(f.value,n.positive),u===n.positive?h.subtract(a,f):h.subtract(f,a);r(a,f);var l=a.value,p=f.value,d=[],v=0;for(var m=0;m<l.length||v>0;m++){var g=(l[m]||0)+(p[m]||0)+v;v=g>=e?1:0,g-=v*e,d.push(g)}return o(d,u)},plus:function(e,t){return h.add(e,t)},subtract:function(t,r){var s=c,u;r?(s=i(t))&&(u=i(r)):u=i(t,s);if(s.sign!==u.sign)return h.add(s,h.negate(u));if(s.sign===n.negative)return h.subtract(h.negate(u),h.negate(s));if(h.compare(s,u)===-1)return h.negate(h.subtract(u,s));var a=s.value,f=u.value,l=[],p=0;for(var d=0;d<a.length;d++){var v=a[d]-p;p=v<f[d]?1:0;var m=p*e+v-f[d];l.push(m)}return o(l,n.positive)},minus:function(e,t){return h.subtract(e,t)},multiply:function(t,n){var r,s=c,u;n?(s=i(t))&&(u=i(n)):u=i(t,s),r=s.sign!==u.sign;var a=s.value,f=u.value,l=[];for(var h=0;h<a.length;h++){l[h]=[];var p=h;while(p--)l[h].push(0)}var d=0;for(var h=0;h<a.length;h++){var v=a[h];for(var p=0;p<f.length||d>0;p++){var m=f[p],g=m?v*m+d:d;d=g>e?Math.floor(g/e):0,g-=d*e,l[h].push(g)}}var y=-1;for(var h=0;h<l.length;h++){var b=l[h].length;b>y&&(y=b)}var w=[],d=0;for(var h=0;h<y||d>0;h++){var E=d;for(var p=0;p<l.length;p++)E+=l[p][h]||0;d=E>e?Math.floor(E/e):0,E-=d*e,w.push(E)}return o(w,r)},times:function(e,t){return h.multiply(e,t)},divmod:function(e,t){var r,u=c,a;t?(u=i(e))&&(a=i(t)):a=i(e,u),r=u.sign!==a.sign;if(o(u.value,u.sign).equals(0))return{quotient:o([0],n.positive),remainder:o([0],n.positive)};if(a.equals(0))throw new Error("Cannot divide by zero");var f=u.value,l=a.value,h=[],p=[];for(var d=f.length-1;d>=0;d--){var e=[f[d]].concat(p),v=s(l,e);h.push(v.result),p=v.remainder}return h.reverse(),{quotient:o(h,r),remainder:o(p,u.sign)}},divide:function(e,t){return h.divmod(e,t).quotient},over:function(e,t){return h.divide(e,t)},mod:function(e,t){return h.divmod(e,t).remainder},remainder:function(e,t){return h.mod(e,t)},pow:function(e,t){var n=c,r;t?(n=i(e))&&(r=i(t)):r=i(e,n);var s=n,f=r;if(o(s.value,s.sign).equals(0))return u;if(f.lesser(0))return u;if(f.equals(0))return a;var l=o(s.value,s.sign);if(f.mod(2).equals(0)){var h=l.pow(f.over(2));return h.times(h)}return l.times(l.pow(f.minus(1)))},next:function(e){var t=e||c;return h.add(t,1)},prev:function(e){var t=e||c;return h.subtract(t,1)},compare:function(e,t){var s=c,o;t?(s=i(e))&&(o=i(t,s)):o=i(e,s),r(s,o);if(s.value.length===1&&o.value.length===1&&s.value[0]===0&&o.value[0]===0)return 0;if(o.sign!==s.sign)return s.sign===n.positive?1:-1;var u=s.sign===n.positive?1:-1,a=s.value,f=o.value;for(var l=a.length-1;l>=0;l--){if(a[l]>f[l])return 1*u;if(f[l]>a[l])return-1*u}return 0},compareTo:function(e,t){return h.compare(e,t)},compareAbs:function(e,t){var r=c,s;return t?(r=i(e))&&(s=i(t,r)):s=i(e,r),r.sign=s.sign=n.positive,h.compare(r,s)},equals:function(e,t){return h.compare(e,t)===0},notEquals:function(e,t){return!h.equals(e,t)},lesser:function(e,t){return h.compare(e,t)<0},greater:function(e,t){return h.compare(e,t)>0},greaterOrEquals:function(e,t){return h.compare(e,t)>=0},lesserOrEquals:function(e,t){return h.compare(e,t)<=0},isPositive:function(e){var t=e||c;return t.sign===n.positive},isNegative:function(e){var t=e||c;return t.sign===n.negative},isEven:function(e){var t=e||c;return t.value[0]%2===0},isOdd:function(e){var t=e||c;return t.value[0]%2===1},toString:function(r){var i=r||c,s="",o=i.value.length;while(o--)i.value[o].toString().length===8?s+=i.value[o]:s+=(e.toString()+i.value[o]).slice(-t);while(s[0]==="0")s=s.slice(1);s.length||(s="0");if(s==="0")return s;var u=i.sign===n.positive?"":"-";return u+s},toJSNumber:function(e){return+h.toString(e)},valueOf:function(e){return h.toJSNumber(e)}};return h},u=o([0],n.positive),a=o([1],n.positive),f=o([1],n.negative),l=function(e,t){function a(e){var t=e[s].toLowerCase();if(s===0&&e[s]==="-"){o=!0;return}if(/[0-9]/.test(t))r.push(i(t));else if(/[a-z]/.test(t))r.push(i(t.charCodeAt(0)-87));else{if(t!=="<")throw new Error(t+" is not a valid character");var n=s;do s++;while(e[s]!==">");r.push(i(e.slice(n+1,s)))}}t=i(t);var n=u,r=[],s,o=!1;for(s=0;s<e.length;s++)a(e);r.reverse();for(s=0;s<r.length;s++)n=n.add(r[s].times(t.pow(s)));return o?-n:n},c=function(e,t){return typeof e=="undefined"?u:typeof t!="undefined"?l(e,t):i(e)};return c.zero=u,c.one=a,c.minusOne=f,c}();typeof module!="undefined"&&(module.exports=bigInt);var bigRat=function(){function e(t,n){return n.equals(0)?t:e(n,t.mod(n))}function t(t,n){return t.times(n).divide(e(t,n))}function n(i,o,u){o=o||bigInt(1),u=u||!1;var a={numerator:i,denominator:o,num:i,denom:o,reduce:function(){var t=e(a.num,a.denom),r=a.num.divide(t),i=a.denom.divide(t);i.lesser(0)&&(r=r.times(-1),i=i.times(-1));if(i.equals(0))throw"Denominator cannot be 0.";return n(r,i,!0)},abs:function(){return a.isPositive()?a:a.negate()},multiply:function(e,t){return e=r(e,t),n(a.num.times(e.num),a.denom.times(e.denom))},times:function(e,t){return a.multiply(e,t)},divide:function(e,t){return e=r(e,t),n(a.num.times(e.denom),a.denom.times(e.num))},over:function(e,t){return a.divide(e,t)},mod:function(e,t){var e=r(e,t);return a.minus(e.times(a.over(e).floor()))},add:function(e,i){e=r(e,i);var s=t(a.denom,e.denom),o=s.divide(a.denom),u=s.divide(e.denom);return o=a.num.times(o),u=e.num.times(u),n(o.add(u),s)},plus:function(e,t){return a.add(e,t)},negate:function(){var e=bigInt.zero.minus(a.num);return n(e,a.denom)},subtract:function(e,t){return e=r(e,t),a.add(e.negate())},minus:function(e,t){return a.subtract(e,t)},isPositive:function(){return a.num.isPositive()},isNegative:function(){return!a.isPositive()},isZero:function(){return a.equals(0,1)},compare:function(e,t){e=r(e,t);if(a.num.equals(e.num)&&a.denom.equals(e.denom))return 0;var n=a.denom.times(e.denom),i=n.greater(0)?1:-1;return a.num.times(e.denom).greater(e.num.times(a.denom))?i:-i},equals:function(e,t){return a.compare(e,t)===0},notEquals:function(e,t){return!a.equals(e,t)},lesser:function(e,t){return a.compare(e,t)<0},lesserOrEquals:function(e,t){return a.compare(e,t)<=0},greater:function(e,t){return a.compare(e,t)>0},greaterOrEquals:function(e,t){return a.compare(e,t)>=0},floor:function(e){var t=a.num.over(a.denom);return e?t:n(t)},ceil:function(e){var t=a.num.divmod(a.denom),r;return r=t.quotient,t.remainder.notEquals(0)&&(r=r.add(1)),e?r:n(r)},round:function(e){return a.add(1,2).floor(e)},toString:function(){var e=a.reduce();return e.num.toString()+"/"+e.denom.toString()},valueOf:function(){return a.num/a.denom},toDecimal:function(e){e=e||10;var t=a.num.divmod(a.denom),n=t.quotient.toString(),r=s(t.remainder.abs(),a.denom),i="";while(i.length<=e){var o;for(o=0;o<=10;o++)if(s(i+o,"1"+Array(i.length+2).join("0")).greater(r)){o--;break}i+=o}while(i.slice(-1)==="0")i=i.slice(0,-1);return i===""?n:n+"."+i}};return u?a:a.reduce()}function r(e,t){return s(e,t)}function i(e){var t=e.split(/e/i);if(t.length>2)throw new Error("Invalid input: too many 'e' tokens");if(t.length>1){var r=!0;t[1][0]==="-"&&(t[1]=t[1].slice(1),r=!1),t[1][0]==="+"&&(t[1]=t[1].slice(1));var s=i(t[0]),o=n(bigInt(10).pow(t[1]));return r?s.times(o):s.over(o)}t=e.split(".");if(t.length>2)throw new Error("Invalid input: too many '.' tokens");if(t.length>1){var u=n(bigInt(t[0])),a=t[1].length;while(t[1][0]==="0")t[1]=t[1].slice(1);var f="1"+Array(a+1).join("0"),l=n(bigInt(t[1]),bigInt(f));return u=u.add(l),t[0][0]==="-"&&(u=u.negate()),u}return n(bigInt(e))}function s(e,t){if(!e)return n(bigInt(0));if(t)return n(bigInt(e),bigInt(t));if(typeof e=="object")return e.instanceofBigInt?n(e):e;var r,s,o=e+"",u=o.split("/");if(u.length>2)throw new Error("Invalid input: too many '/' tokens");if(u.length>1){var a=u[0].split("_");if(a.length>2)throw new Error("Invalid input: too many '_' tokens");if(a.length>1){var f=a[0][0]!=="-";return r=bigInt(a[0]).times(u[1]),f?r=r.add(a[1]):r=r.subtract(a[1]),s=bigInt(u[1]),n(r,s).reduce()}return n(bigInt(u[0]),bigInt(u[1]))}return i(o)}return typeof require!="undefined"&&(bigInt=require("big-integer")),s.zero=s(0),s.one=s(1),s.minusOne=s(-1),s}();typeof module!="undefined"&&module.hasOwnProperty("exports")&&(module.exports=bigRat);
var bigInt=function(e){"use strict";function o(e,t){this.value=e,this.sign=t,this.isSmall=!1}function u(e){this.value=e,this.sign=e<0,this.isSmall=!0}function a(e){return-r<e&&e<r}function f(e){return e<1e7?[e]:e<1e14?[e%1e7,Math.floor(e/1e7)]:[e%1e7,Math.floor(e/1e7)%1e7,Math.floor(e/1e14)]}function l(e){c(e);var n=e.length;if(n<4&&A(e,i)<0)switch(n){case 0:return 0;case 1:return e[0];case 2:return e[0]+e[1]*t;default:return e[0]+(e[1]+e[2]*t)*t}return e}function c(e){var t=e.length;while(e[--t]===0);e.length=t+1}function h(e){var t=new Array(e),n=-1;while(++n<e)t[n]=0;return t}function p(e){return e>0?Math.floor(e):Math.ceil(e)}function d(e,n){var r=e.length,i=n.length,s=new Array(r),o=0,u=t,a,f;for(f=0;f<i;f++)a=e[f]+n[f]+o,o=a>=u?1:0,s[f]=a-o*u;while(f<r)a=e[f]+o,o=a===u?1:0,s[f++]=a-o*u;return o>0&&s.push(o),s}function v(e,t){return e.length>=t.length?d(e,t):d(t,e)}function m(e,n){var r=e.length,i=new Array(r),s=t,o,u;for(u=0;u<r;u++)o=e[u]+n,n=Math.floor(o/s),i[u]=o%s;while(n>0)i[u++]=n%s,n=Math.floor(n/s);return i}function g(e,n){var r=e.length,i=n.length,s=new Array(r),o=0,u=t,a,f;for(a=0;a<i;a++)f=e[a]-o-n[a],f<0?(f+=u,o=1):o=0,s[a]=f;for(a=i;a<r;a++){f=e[a]-o;if(!(f<0)){s[a++]=f;break}f+=u,s[a]=f}for(;a<r;a++)s[a]=e[a];return c(s),s}function y(e,t,n){var r,i;return A(e,t)>=0?r=g(e,t):(r=g(t,e),n=!n),r=l(r),typeof r=="number"?(n&&(r=-r),new u(r)):new o(r,n)}function b(e,n,r){var i=e.length,s=new Array(i),a=-n,f=t,c,h;for(c=0;c<i;c++)h=e[c]+a,a=Math.floor(h/f),s[c]=h<0?h%f+f:h;return s=l(s),typeof s=="number"?(r&&(s=-s),new u(s)):new o(s,r)}function w(e,n){var r=e.length,i=n.length,s=r+i,o=h(s),u=t,a,f,l,p,d;for(l=0;l<r;++l){p=e[l];for(var v=0;v<i;++v)d=n[v],a=p*d+o[l+v],f=Math.floor(a/u),o[l+v]=a-f*u,o[l+v+1]+=f}return c(o),o}function E(e,n){var r=e.length,i=new Array(r),s=t,o=0,u,a;for(a=0;a<r;a++)u=e[a]*n+o,o=Math.floor(u/s),i[a]=u-o*s;while(o>0)i[a++]=o%s,o=Math.floor(o/s);return i}function S(e,t){var n=[];while(t-->0)n.push(0);return n.concat(e)}function x(e,t){var n=Math.max(e.length,t.length);if(n<=400)return w(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),s=t.slice(n),o=t.slice(0,n),u=x(i,o),a=x(r,s),f=x(v(i,r),v(o,s));return v(v(u,S(g(g(f,u),a),n)),S(a,2*n))}function T(e){var n=e.length,r=h(n+n),i=t,s,o,u,a,f;for(u=0;u<n;u++){a=e[u];for(var l=0;l<n;l++)f=e[l],s=a*f+r[u+l],o=Math.floor(s/i),r[u+l]=s-o*i,r[u+l+1]+=o}return c(r),r}function N(e,n){var r=e.length,i=n.length,s=t,o=h(n.length),u=n[i-1],a=Math.ceil(s/(2*u)),f=E(e,a),c=E(n,a),p,d,v,m,g,y,b;f.length<=r&&f.push(0),c.length<=i&&c.push(0),u=c[i-1];for(d=r-i;d>=0;d--){p=s-1,f[d+i]!==u&&(p=Math.floor((f[d+i]*s+f[d+i-1])/u)),v=0,m=0,y=c.length;for(g=0;g<y;g++)v+=p*c[g],b=Math.floor(v/s),m+=f[d+g]-(v-b*s),v=b,m<0?(f[d+g]=m+s,m=-1):(f[d+g]=m,m=0);while(m!==0){p-=1,v=0;for(g=0;g<y;g++)v+=f[d+g]-s+c[g],v<0?(f[d+g]=v+s,v=0):(f[d+g]=v,v=1);m+=v}o[d]=p}return f=k(f,a)[0],[l(o),l(f)]}function C(e,n){var r=e.length,i=n.length,s=[],o=[],u=t,a,f,c,h,p;while(r){o.unshift(e[--r]);if(A(o,n)<0){s.push(0);continue}o.length===1&&o[0]===0?a=0:(f=o.length,c=o[f-1]*u+o[f-2],h=n[i-1]*u+n[i-2],f>i&&(c=(c+1)*u),a=Math.ceil(c/h));do{p=E(n,a);if(A(p,o)<=0)break;a--}while(a);s.push(a);if(!a)continue;o=g(o,p)}return s.reverse(),[l(s),l(o)]}function k(e,n){var r=e.length,i=h(r),s=t,o,u,a,f;a=0;for(o=r-1;o>=0;--o)f=a*s+e[o],u=p(f/n),a=f-u*n,i[o]=u|0;return[i,a|0]}function L(e,n){var r,i=z(n),s=e.value,a=i.value,c;if(a===0)throw new Error("Cannot divide by zero");if(e.isSmall)return i.isSmall?[new u(p(s/a)),new u(s%a)]:[W[0],e];if(i.isSmall){if(a===1)return[e,W[0]];if(a==-1)return[e.negate(),W[0]];var h=Math.abs(a);if(h<t){r=k(s,h),c=l(r[0]);var d=r[1];return e.sign&&(d=-d),typeof c=="number"?(e.sign!==i.sign&&(c=-c),[new u(c),new u(d)]):[new o(c,e.sign!==i.sign),new u(d)]}a=f(h)}var v=A(s,a);if(v===-1)return[W[0],e];if(v===0)return[W[1],W[0]];s.length+a.length<=200?r=N(s,a):r=C(s,a),c=r[0];var m=e.sign!==i.sign,g=r[1],y=e.sign;return typeof c=="number"?(m&&(c=-c),c=new u(c)):c=new o(c,m),typeof g=="number"?(y&&(g=-g),g=new u(g)):g=new o(g,y),[c,g]}function A(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}function D(e){return(typeof e=="number"||typeof e=="string")&&+Math.abs(e)<=t||e instanceof o&&e.value.length<=1}function P(e,t,n){t=z(t);var r=e.isNegative(),i=t.isNegative(),s=r?e.not():e,o=i?t.not():t,u=[],a=[],f=!1,l=!1;while(!f||!l)s.isZero()?(f=!0,u.push(r?1:0)):r?u.push(s.isEven()?1:0):u.push(s.isEven()?0:1),o.isZero()?(l=!0,a.push(i?1:0)):i?a.push(o.isEven()?1:0):a.push(o.isEven()?0:1),s=s.over(2),o=o.over(2);var c=[];for(var h=0;h<u.length;h++)c.push(n(u[h],a[h]));var p=bigInt(c.pop()).negate().times(bigInt(2).pow(c.length));while(c.length)p=p.add(bigInt(c.pop()).times(bigInt(2).pow(c.length)));return p}function H(e,t){return e=z(e),t=z(t),e.greater(t)?e:t}function B(e,t){return e=z(e),t=z(t),e.lesser(t)?e:t}function j(e,t){return e=z(e).abs(),t=z(t).abs(),e.equals(t)?e:e.isZero()?t:t.isZero()?e:e.isEven()?t.isOdd()?j(e.divide(2),t):j(e.divide(2),t.divide(2)).multiply(2):t.isEven()?j(e,t.divide(2)):e.greater(t)?j(e.subtract(t).divide(2),t):j(t.subtract(e).divide(2),e)}function F(e,t){return e=z(e).abs(),t=z(t).abs(),e.multiply(t).divide(j(e,t))}function I(e,n){e=z(e),n=z(n),e.isSmall&&(e=f(e)),n.isSmall&&(n=f(n));var r=B(e,n),i=H(e,n),s=i.subtract(r),u=s.value.length-1,a=[],c=!0;for(var h=u;h>=0;h--){var d=c?s.value[h]:t,v=p(Math.random()*d);a.unshift(v),v<d&&(c=!1)}return a=l(a),r.add(new o(a,!1,typeof a=="number"))}function R(e){var t=e.value;return typeof t=="number"&&(t=[t]),t.length===1&&t[0]<=36?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t[0]):"<"+t+">"}function U(e,t){t=bigInt(t);if(t.isZero()){if(e.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1))return e.isZero()?"0":e.isNegative()?(new Array(1-e)).join("10"):"1"+(new Array(+e)).join("01");var n="";e.isNegative()&&t.isPositive()&&(n="-",e=e.abs());if(t.equals(1))return e.isZero()?"0":n+(new Array(+e+1)).join(1);var r=[],i=e,s;while(i.isNegative()||i.compareAbs(t)>=0){s=i.divmod(t),i=s.quotient;var o=s.remainder;o.isNegative()&&(o=t.minus(o).abs(),i=i.next()),r.push(R(o))}return r.push(R(i)),n+r.reverse().join("")}function z(e){if(e instanceof o||e instanceof u)return e;if(typeof e=="number"){if(a(e))return new u(e);e=String(e)}if(typeof e=="string"){if(a(+e)){var t=+e;if(t===p(t))return new u(t);throw"Invalid integer: "+e}var r=e[0]==="-";r&&(e=e.slice(1));var i=e.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+f.join("e"));if(i.length===2){var s=i[1];s[0]==="+"&&(s=s.slice(1)),s=+s;if(s!==p(s)||!a(s))throw new Error("Invalid integer: "+s+" is not a valid exponent.");var f=i[0],l=f.indexOf(".");l>=0&&(s-=f.length-l,f=f.slice(0,l)+f.slice(l+1));if(s<0)throw new Error("Cannot include negative exponent part for integers");f+=(new Array(s+1)).join("0"),e=f}var h=/^([0-9][0-9]*)$/.test(e);if(!h)throw new Error("Invalid integer: "+e);var d=[],v=e.length,m=n,g=v-m;while(v>0)d.push(+e.slice(g,v)),g-=m,g<0&&(g=0),v-=m;return c(d),new o(d,r)}}var t=1e7,n=7,r=9007199254740992,i=f(r),s=Math.log(r);o.prototype.add=function(e){var n,r=z(e);if(this.sign!==r.sign)return this.subtract(r.negate());var i=this.value,s=r.value;if(r.isSmall){if(a(s+t))return new o(m(i,Math.abs(s)),this.sign);s=f(Math.abs(s))}return new o(v(i,s),this.sign)},o.prototype.plus=o.prototype.add,u.prototype.add=function(e){var n=z(e);if(this.sign!==n.sign)return this.subtract(n.negate());var r=this.value,i=n.value;if(n.isSmall){if(a(r+i))return new u(r+i);i=f(Math.abs(i))}return a(r+t)?new o(m(i,Math.abs(r)),r<0):new o(v(i,f(Math.abs(r))),r<0)},u.prototype.plus=u.prototype.add,o.prototype.subtract=function(e){var t=z(e);if(this.sign!==t.sign)return this.add(t.negate());var n=this.value,r=t.value;return t.isSmall?b(n,Math.abs(r),this.sign):y(n,r,this.sign)},o.prototype.minus=o.prototype.subtract,u.prototype.subtract=function(e){var t=z(e);if(this.sign!==t.sign)return this.add(t.negate());var n=this.value,r=t.value;return t.isSmall?new u(n-r):b(r,Math.abs(n),n>=0)},u.prototype.minus=u.prototype.subtract,o.prototype.negate=function(){return new o(this.value,!this.sign)},u.prototype.negate=function(){var e=this.sign,t=new u(-this.value);return t.sign=!e,t},o.prototype.abs=function(){return new o(this.value,!1)},u.prototype.abs=function(){return new u(Math.abs(this.value))},o.prototype.multiply=function(e){var n,r=z(e),i=this.value,s=r.value,u=this.sign!==r.sign,a;if(r.isSmall){if(s===0)return W[0];if(s===1)return this;if(s===-1)return this.negate();a=Math.abs(s);if(a<t)return new o(E(i,a),u);s=f(a)}return i.length+s.length>4e3?new o(x(i,s),u):new o(w(i,s),u)},o.prototype.times=o.prototype.multiply,u.prototype.multiply=function(e){var n=z(e),r=this.value,i=n.value;if(r===0)return W[0];if(r===1)return n;if(r===-1)return n.negate();if(n.isSmall){if(a(r*i))return new u(r*i);i=f(Math.abs(i))}var s=Math.abs(r);return s<t?new o(E(i,s),this.sign!==n.sign):new o(w(i,f(s)),this.sign!==n.sign)},u.prototype.times=u.prototype.multiply,o.prototype.square=function(){return new o(T(this.value),!1)},u.prototype.square=function(){var e=this.value*this.value;return a(e)?new u(e):new o(T(f(Math.abs(this.value))),!1)},o.prototype.divmod=function(e){var t=L(this,e);return{quotient:t[0],remainder:t[1]}},u.prototype.divmod=o.prototype.divmod,o.prototype.divide=function(e){return L(this,e)[0]},u.prototype.over=u.prototype.divide=o.prototype.over=o.prototype.divide,o.prototype.mod=function(e){return L(this,e)[1]},u.prototype.remainder=u.prototype.mod=o.prototype.remainder=o.prototype.mod,o.prototype.pow=function(e){var t=z(e),n=this.value,r=t.value,i,s,o;if(r===0)return W[1];if(t.sign)return n===1?W[1]:n===-1?isEven(t)?W[1]:W[-1]:W[0];if(!t.isSmall)throw new Error("The exponent "+t.toString()+" is too large.");if(this.isSmall){if(a(i=Math.pow(n,r)))return new u(p(i));if(n===0)return W[0];if(n===1)return W[1]}s=this,o=W[1];for(;;){r&!0&&(o=o.times(s),--r);if(r===0)break;r/=2,s=s.square()}return o},u.prototype.pow=o.prototype.pow,o.prototype.modPow=function(e,t){e=z(e),t=z(t);if(t.isZero())throw new Error("Cannot take modPow with modulus 0");var n=W[1],r=this.mod(t);if(r.isZero())return W[0];while(e.isPositive())e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t);return n},u.prototype.modPow=o.prototype.modPow,o.prototype.compareAbs=function(e){var t=z(e),n=this.value,r=t.value;return t.isSmall?1:A(n,r)},u.prototype.compareAbs=function(e){var t=z(e),n=Math.abs(this.value),r=t.value;return t.isSmall?(r=Math.abs(r),n===r?0:n>r?1:-1):-1},o.prototype.compare=function(e){var t=z(e),n=this.value,r=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:A(n,r)*(this.sign?-1:1)},o.prototype.compareTo=o.prototype.compare,u.prototype.compare=function(e){var t=z(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0!==t.sign?n<0?-1:1:n<0?1:-1},u.prototype.compareTo=u.prototype.compare,o.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=o.prototype.eq=o.prototype.equals,o.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=o.prototype.neq=o.prototype.notEquals,o.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=o.prototype.gt=o.prototype.greater,o.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=o.prototype.lt=o.prototype.lesser,o.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=o.prototype.geq=o.prototype.greaterOrEquals,o.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=o.prototype.leq=o.prototype.lesserOrEquals,o.prototype.isEven=function(){return(this.value[0]&1)===0},u.prototype.isEven=function(){return(this.value&1)===0},o.prototype.isOdd=function(){return(this.value[0]&1)===1},u.prototype.isOdd=function(){return(this.value&1)===1},o.prototype.isPositive=function(){return!this.sign},u.prototype.isPositive=function(){return this.value>0},o.prototype.isNegative=function(){return this.sign},u.prototype.isNegative=function(){return this.value<0},o.prototype.isUnit=function(){return!1},u.prototype.isUnit=function(){return Math.abs(this.value)===1},o.prototype.isZero=function(){return!1},u.prototype.isZero=function(){return this.value===0},o.prototype.isDivisibleBy=function(e){var t=z(e),n=t.value;return n===0?!1:n===1?!0:n===2?this.isEven():this.mod(t).equals(W[0])},u.prototype.isDivisibleBy=o.prototype.isDivisibleBy,o.prototype.isPrime=function(){var e=this.abs(),t=e.prev();if(e.isUnit())return!1;if(e.equals(2)||e.equals(3)||e.equals(5))return!0;if(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))return!1;if(e.lesser(25))return!0;var n=[2,3,5,7,11,13,17,19],r=t,i,s,o,u;while(r.isEven())r=r.divide(2);for(o=0;o<n.length;o++){u=bigInt(n[o]).modPow(r,e);if(u.equals(W[1])||u.equals(t))continue;for(s=!0,i=r;s&&i.lesser(t);i=i.multiply(2))u=u.square().mod(e),u.equals(t)&&(s=!1);if(s)return!1}return!0},u.prototype.isPrime=o.prototype.isPrime,o.prototype.next=function(){var e=this.value;return this.sign?b(e,1,this.sign):new o(m(e,1),this.sign)},u.prototype.next=function(){var e=this.value;return e+1<r?new u(e+1):new o(i,!1)},o.prototype.prev=function(){var e=this.value;return this.sign?new o(m(e,1),!0):b(e,1,this.sign)},u.prototype.prev=function(){var e=this.value;return e-1>-r?new u(e-1):new o(i,!0)};var O=[1];while(O[O.length-1]<=t)O.push(2*O[O.length-1]);var M=O.length,_=O[M-1];o.prototype.shiftLeft=function(e){if(!D(e))return e.isNegative()?this.shiftRight(e.abs()):this.times(W[2].pow(e));e=+e;if(e<0)return this.shiftRight(-e);var t=this;while(e>=M)t=t.multiply(_),e-=M-1;return t.multiply(O[e])},u.prototype.shiftLeft=o.prototype.shiftLeft,o.prototype.shiftRight=function(e){var t;if(!D(e))return e.isNegative()?this.shiftLeft(e.abs()):(t=this.divmod(W[2].pow(e)),t.remainder.isNegative()?t.quotient.prev():t.quotient);e=+e;if(e<0)return this.shiftLeft(-e);var n=this;while(e>=M){if(n.isZero())return n;t=L(n,_),n=t[1].isNegative()?t.quotient.prev():t[0],e-=M-1}return t=L(n,O[e]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=o.prototype.shiftRight,o.prototype.not=function(){return this.negate().prev()},u.prototype.not=o.prototype.not,o.prototype.and=function(e){return P(this,e,function(e,t){return e&t})},u.prototype.and=o.prototype.and,o.prototype.or=function(e){return P(this,e,function(e,t){return e|t})},u.prototype.or=o.prototype.or,o.prototype.xor=function(e){return P(this,e,function(e,t){return e^t})},u.prototype.xor=o.prototype.xor;var q=function(e,t){var n=W[0],r=W[1],i=e.length;if(2<=t&&t<=36&&i<=s/Math.log(t))return new u(parseInt(e,t));t=z(t);var o=[],a,f=e[0]==="-";for(a=f?1:0;a<e.length;a++){var l=e[a].toLowerCase(),c=l.charCodeAt(0);if(48<=c&&c<=57)o.push(z(l));else if(97<=c&&c<=122)o.push(z(l.charCodeAt(0)-87));else{if(l!=="<")throw new Error(l+" is not a valid character");var h=a;do a++;while(e[a]!==">");o.push(z(e.slice(h+1,a)))}}o.reverse();for(a=0;a<o.length;a++)n=n.add(o[a].times(r)),r=r.times(t);return f?n.negate():n};o.prototype.toString=function(t){t===e&&(t=10);if(t!==10)return U(this,t);var n=this.value,r=n.length,i=String(n[--r]),s="0000000",o;while(--r>=0)o=String(n[r]),i+=s.slice(o.length)+o;var u=this.sign?"-":"";return u+i},u.prototype.toString=function(t){return t===e&&(t=10),t!=10?U(this,t):String(this.value)},o.prototype.valueOf=function(){return this.isSmall?this.value:+this.toString()},o.prototype.toJSNumber=o.prototype.valueOf;var W=function(e,t){return typeof e=="undefined"?W[0]:typeof t!="undefined"?+t===10?z(e):q(e,t):z(e)};for(var X=0;X<1e3;X++)W[X]=new u(X),X>0&&(W[-X]=new u(-X));return W.one=W[1],W.zero=W[0],W.minusOne=W[-1],W.max=H,W.min=B,W.gcd=j,W.lcm=F,W.isInstance=function(e){return e instanceof o||e instanceof u},W.randBetween=I,W}();typeof module!="undefined"&&(module.exports=bigInt);var bigRat=function(){"use strict";function e(e,t){if(t.isZero())throw"Denominator cannot be 0.";this.numerator=this.num=e,this.denominator=this.denom=t}function r(n,r){var i=t(n,r),s=n.over(i),o=r.over(i);return o.isNegative()?new e(s.negate(),o.negate()):new e(s,o)}function i(e,t){return o(e,t)}function s(t){var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid input: too many 'e' tokens");if(n.length>1){var i=!0;n[1][0]==="-"&&(n[1]=n[1].slice(1),i=!1),n[1][0]==="+"&&(n[1]=n[1].slice(1));var o=s(n[0]),u=new e(bigInt(10).pow(n[1]),bigInt[1]);return i?o.times(u):o.over(u)}n=t.split(".");if(n.length>2)throw new Error("Invalid input: too many '.' tokens");if(n.length>1){var a=new e(bigInt(n[0]),bigInt[1]),f=n[1].length;while(n[1][0]==="0")n[1]=n[1].slice(1);var l="1"+Array(f+1).join("0"),c=r(bigInt(n[1]),bigInt(l));return a=a.add(c),n[0][0]==="-"&&(a=a.negate()),a}return new e(bigInt(t),bigInt[1])}function o(t,n){if(!t)return new e(bigInt(0),bigInt[1]);if(n)return r(bigInt(t),bigInt(n));if(bigInt.isInstance(t))return new e(t,bigInt[1]);if(t instanceof e)return t;var i,o,u=String(t),a=u.split("/");if(a.length>2)throw new Error("Invalid input: too many '/' tokens");if(a.length>1){var f=a[0].split("_");if(f.length>2)throw new Error("Invalid input: too many '_' tokens");if(f.length>1){var l=f[0][0]!=="-";return i=bigInt(f[0]).times(a[1]),l?i=i.add(f[1]):i=i.subtract(f[1]),o=bigInt(a[1]),r(i,o)}return r(bigInt(a[0]),bigInt(a[1]))}return s(u)}typeof require=="function"&&(bigInt=require("big-integer"));var t=bigInt.gcd,n=bigInt.lcm;return e.prototype.add=function(e,t){var s=i(e,t),o=n(this.denom,s.denom),u=o.divide(this.denom),a=o.divide(s.denom);return u=this.num.times(u),a=s.num.times(a),r(u.add(a),o)},e.prototype.plus=e.prototype.add,e.prototype.subtract=function(e,t){var n=i(e,t);return this.add(n.negate())},e.prototype.minus=e.prototype.subtract,e.prototype.multiply=function(e,t){var n=i(e,t);return r(this.num.times(n.num),this.denom.times(n.denom))},e.prototype.times=e.prototype.multiply,e.prototype.divide=function(e,t){var n=i(e,t);return r(this.num.times(n.denom),this.denom.times(n.num))},e.prototype.over=e.prototype.divide,e.prototype.reciprocate=function(){return new e(this.denom,this.num)},e.prototype.mod=function(e,t){var n=i(e,t);return this.minus(n.times(this.over(n).floor()))},e.prototype.floor=function(t){var n=this.num.divmod(this.denom),r;return n.remainder.isZero()||!n.quotient.sign?r=n.quotient:r=n.quotient.prev(),t?r:new e(r,bigInt[1])},e.prototype.ceil=function(t){var n=this.num.divmod(this.denom),r;return n.remainder.isZero()||n.quotient.sign?r=n.quotient:r=n.quotient.next(),t?r:new e(r,bigInt[1])},e.prototype.round=function(e){return this.add(1,2).floor(e)},e.prototype.compareAbs=function(e,t){var n=i(e,t);return this.denom.equals(n.denom)?this.num.compareAbs(n.num):this.num.times(n.denom).compareAbs(n.num.times(this.denom))},e.prototype.compare=function(e,t){var n=i(e,t);if(this.denom.equals(n.denom))return this.num.compare(n.num);var r=this.denom.sign===n.denom.sign?1:-1;return r*this.num.times(n.denom).compare(n.num.times(this.denom))},e.prototype.compareTo=e.prototype.compare,e.prototype.equals=function(e,t){return this.compare(e,t)===0},e.prototype.eq=e.prototype.equals,e.prototype.notEquals=function(e,t){return this.compare(e,t)!==0},e.prototype.neq=e.prototype.notEquals,e.prototype.lesser=function(e,t){return this.compare(e,t)<0},e.prototype.lt=e.prototype.lesser,e.prototype.lesserOrEquals=function(e,t){return this.compare(e,t)<=0},e.prototype.leq=e.prototype.lesserOrEquals,e.prototype.greater=function(e,t){return this.compare(e,t)>0},e.prototype.gt=e.prototype.greater,e.prototype.greaterOrEquals=function(e,t){return this.compare(e,t)>=0},e.prototype.geq=e.prototype.greaterOrEquals,e.prototype.abs=function(){return this.isPositive()?this:this.negate()},e.prototype.negate=function(){return this.denom.sign?new e(this.num,this.denom.negate()):new e(this.num.negate(),this.denom)},e.prototype.isNegative=function(){return this.num.sign!==this.denom.sign},e.prototype.isPositive=function(){return this.num.sign===this.denom.sign},e.prototype.isZero=function(){return this.num.isZero()},e.prototype.toDecimal=function(e){e=e||10;var t=this.num.divmod(this.denom),n=t.quotient.toString(),r=o(t.remainder.abs(),this.denom),i="";while(i.length<=e){var s;for(s=0;s<=10;s++)if(o(i+s,"1"+Array(i.length+2).join("0")).greater(r)){s--;break}i+=s}while(i.slice(-1)==="0")i=i.slice(0,-1);return i===""?n:n+"."+i},e.prototype.toString=function(){return String(this.num)+"/"+String(this.denom)},e.prototype.valueOf=function(){return this.num/this.denom},o.zero=o(0),o.one=o(1),o.minusOne=o(-1),o}();typeof module!="undefined"&&module.hasOwnProperty("exports")&&(module.exports=bigRat);

@@ -0,180 +1,189 @@

;var bigRat = (function () {
"use strict";
if (typeof require === "function") {
bigInt = require("big-integer");
}
function BigRational(num, denom) {
// Alias properties kept for backwards compatability
if (denom.isZero()) throw "Denominator cannot be 0.";
this.numerator = this.num = num;
this.denominator = this.denom = denom;
}
var bigRat = (function () {
if (typeof require !== "undefined") {
bigInt = require("big-integer");
}
function gcd(a, b) {
if(b.equals(0)) {
return a;
var gcd = bigInt.gcd,
lcm = bigInt.lcm;
function reduce(n, d) {
var divisor = gcd(n, d),
num = n.over(divisor),
denom = d.over(divisor);
if (denom.isNegative()) {
return new BigRational(num.negate(), denom.negate());
}
return gcd(b, a.mod(b));
return new BigRational(num, denom);
}
function lcm(a, b) {
return a.times(b).divide(gcd(a, b));
}
function create(numerator, denominator, preventReduce) {
denominator = denominator || bigInt(1);
preventReduce = preventReduce || false;
var obj = {
numerator: numerator,
denominator: denominator,
num: numerator,
denom: denominator,
reduce: function () {
var divisor = gcd(obj.num, obj.denom);
var num = obj.num.divide(divisor);
var denom = obj.denom.divide(divisor);
if(denom.lesser(0)) {
num = num.times(-1);
denom = denom.times(-1);
}
if(denom.equals(0)) {
throw "Denominator cannot be 0.";
}
return create(num, denom, true);
},
abs: function () {
if (obj.isPositive()) return obj;
return obj.negate();
},
multiply: function (n, d) {
n = interpret(n, d);
return create(obj.num.times(n.num), obj.denom.times(n.denom));
},
times: function (n, d) {
return obj.multiply(n, d);
},
divide: function (n, d) {
n = interpret(n, d);
return create(obj.num.times(n.denom), obj.denom.times(n.num));
},
over: function (n, d) {
return obj.divide(n, d);
},
mod: function (n, d) {
var n = interpret(n, d);
return obj.minus(n.times(obj.over(n).floor()));
},
add: function (n, d) {
n = interpret(n, d);
var multiple = lcm(obj.denom, n.denom);
var a = multiple.divide(obj.denom);
var b = multiple.divide(n.denom);
a = obj.num.times(a);
b = n.num.times(b);
return create(a.add(b), multiple);
},
plus: function (n, d) {
return obj.add(n, d);
},
negate: function () {
var num = bigInt.zero.minus(obj.num);
return create(num, obj.denom);
},
subtract: function (n, d) {
n = interpret(n, d);
return obj.add(n.negate());
},
minus: function (n, d) {
return obj.subtract(n, d);
},
isPositive: function () {
return obj.num.isPositive();
},
isNegative: function () {
return !obj.isPositive();
},
isZero: function () {
return obj.equals(0, 1);
},
compare: function (n, d) {
n = interpret(n, d);
if(obj.num.equals(n.num) && obj.denom.equals(n.denom)) {
return 0;
}
var newDenom = obj.denom.times(n.denom);
var comparison = newDenom.greater(0) ? 1 : -1;
if(obj.num.times(n.denom).greater(n.num.times(obj.denom))) {
return comparison;
} else {
return -comparison;
}
},
equals: function (n, d) {
return obj.compare(n, d) === 0;
},
notEquals: function (n, d) {
return !obj.equals(n, d);
},
lesser: function (n, d) {
return obj.compare(n, d) < 0;
},
lesserOrEquals: function (n, d) {
return obj.compare(n, d) <= 0;
},
greater: function (n, d) {
return obj.compare(n, d) > 0;
},
greaterOrEquals: function (n, d) {
return obj.compare(n, d) >= 0;
},
floor: function (toBigInt) {
var floor = obj.num.over(obj.denom);
if(toBigInt) {
return floor;
}
return create(floor);
},
ceil: function (toBigInt) {
var div = obj.num.divmod(obj.denom);
var ceil;
BigRational.prototype.add = function (n, d) {
var v = interpret(n, d),
multiple = lcm(this.denom, v.denom),
a = multiple.divide(this.denom),
b = multiple.divide(v.denom);
ceil = div.quotient;
if(div.remainder.notEquals(0)) {
ceil = ceil.add(1);
a = this.num.times(a);
b = v.num.times(b);
return reduce(a.add(b), multiple);
};
BigRational.prototype.plus = BigRational.prototype.add;
BigRational.prototype.subtract = function (n, d) {
var v = interpret(n, d);
return this.add(v.negate());
};
BigRational.prototype.minus = BigRational.prototype.subtract;
BigRational.prototype.multiply = function (n, d) {
var v = interpret(n, d);
return reduce(this.num.times(v.num), this.denom.times(v.denom));
};
BigRational.prototype.times = BigRational.prototype.multiply;
BigRational.prototype.divide = function (n, d) {
var v = interpret(n, d);
return reduce(this.num.times(v.denom), this.denom.times(v.num));
};
BigRational.prototype.over = BigRational.prototype.divide;
BigRational.prototype.reciprocate = function () {
return new BigRational(this.denom, this.num);
};
BigRational.prototype.mod = function (n, d) {
var v = interpret(n, d);
return this.minus(v.times(this.over(v).floor()));
};
BigRational.prototype.floor = function (toBigInt) {
var divmod = this.num.divmod(this.denom),
floor;
if (divmod.remainder.isZero() || !divmod.quotient.sign) {
floor = divmod.quotient;
}
else floor = divmod.quotient.prev();
if (toBigInt) return floor;
return new BigRational(floor, bigInt[1]);
};
BigRational.prototype.ceil = function (toBigInt) {
var divmod = this.num.divmod(this.denom),
ceil;
if (divmod.remainder.isZero() || divmod.quotient.sign) {
ceil = divmod.quotient;
}
else ceil = divmod.quotient.next();
if (toBigInt) return ceil;
return new BigRational(ceil, bigInt[1]);
};
BigRational.prototype.round = function (toBigInt) {
return this.add(1, 2).floor(toBigInt);
};
BigRational.prototype.compareAbs = function (n, d) {
var v = interpret(n, d);
if (this.denom.equals(v.denom)) {
return this.num.compareAbs(v.num);
}
return this.num.times(v.denom).compareAbs(v.num.times(this.denom));
};
BigRational.prototype.compare = function (n, d) {
var v = interpret(n, d);
if (this.denom.equals(v.denom)) {
return this.num.compare(v.num);
}
var comparison = this.denom.sign === v.denom.sign ? 1 : -1;
return comparison * this.num.times(v.denom).compare(v.num.times(this.denom));
};
BigRational.prototype.compareTo = BigRational.prototype.compare;
BigRational.prototype.equals = function (n, d) {
return this.compare(n, d) === 0;
};
BigRational.prototype.eq = BigRational.prototype.equals;
BigRational.prototype.notEquals = function (n, d) {
return this.compare(n, d) !== 0;
};
BigRational.prototype.neq = BigRational.prototype.notEquals;
BigRational.prototype.lesser = function (n, d) {
return this.compare(n, d) < 0;
};
BigRational.prototype.lt = BigRational.prototype.lesser;
BigRational.prototype.lesserOrEquals = function (n, d) {
return this.compare(n, d) <= 0;
};
BigRational.prototype.leq = BigRational.prototype.lesserOrEquals;
BigRational.prototype.greater = function (n, d) {
return this.compare(n, d) > 0;
};
BigRational.prototype.gt = BigRational.prototype.greater;
BigRational.prototype.greaterOrEquals = function (n, d) {
return this.compare(n, d) >= 0;
};
BigRational.prototype.geq = BigRational.prototype.greaterOrEquals;
BigRational.prototype.abs = function () {
if (this.isPositive()) return this;
return this.negate();
};
BigRational.prototype.negate = function () {
if (this.denom.sign) {
return new BigRational(this.num, this.denom.negate());
}
return new BigRational(this.num.negate(), this.denom);
};
BigRational.prototype.isNegative = function () {
return this.num.sign !== this.denom.sign;
};
BigRational.prototype.isPositive = function () {
return this.num.sign === this.denom.sign;
};
BigRational.prototype.isZero = function () {
return this.num.isZero();
};
BigRational.prototype.toDecimal = function (digits) {
digits = digits || 10;
var n = this.num.divmod(this.denom);
var intPart = n.quotient.toString();
var remainder = parse(n.remainder.abs(), this.denom);
var decPart = "";
while (decPart.length <= digits) {
var i;
for (i = 0; i <= 10; i++) {
if (parse(decPart + i, "1" + Array(decPart.length + 2).join("0")).greater(remainder)) {
i--;
break;
}
if(toBigInt) {
return ceil;
}
return create(ceil);
},
round: function (toBigInt) {
return obj.add(1, 2).floor(toBigInt);
},
toString: function () {
var o = obj.reduce();
return o.num.toString() + "/" + o.denom.toString();
},
valueOf: function() {
return obj.num / obj.denom;
},
toDecimal: function (digits) {
digits = digits || 10;
var n = obj.num.divmod(obj.denom);
var intPart = n.quotient.toString();
var remainder = parse(n.remainder.abs(), obj.denom);
var decPart = "";
while(decPart.length <= digits) {
var i;
for(i = 0; i <= 10; i++) {
if(parse(decPart + i, "1" + Array(decPart.length + 2).join("0")).greater(remainder)) {
i--;
break;
}
}
decPart += i;
}
while(decPart.slice(-1) === "0") {
decPart = decPart.slice(0, -1);
}
if(decPart === "") {
return intPart;
}
return intPart + "." + decPart;
}
};
return preventReduce ? obj : obj.reduce();
}
decPart += i;
}
while (decPart.slice(-1) === "0") {
decPart = decPart.slice(0, -1);
}
if (decPart === "") {
return intPart;
}
return intPart + "." + decPart;
};
BigRational.prototype.toString = function () {
return String(this.num) + "/" + String(this.denom);
};
BigRational.prototype.valueOf = function () {
return this.num / this.denom;
};
function interpret(n, d) {

@@ -198,3 +207,3 @@ return parse(n, d);

var significand = parseDecimal(parts[0]);
var exponent = create(bigInt(10).pow(parts[1]));
var exponent = new BigRational(bigInt(10).pow(parts[1]), bigInt[1]);
if(isPositive) {

@@ -211,3 +220,3 @@ return significand.times(exponent);

if(parts.length > 1) {
var intPart = create(bigInt(parts[0]));
var intPart = new BigRational(bigInt(parts[0]), bigInt[1]);
var length = parts[1].length;

@@ -218,3 +227,3 @@ while(parts[1][0] === "0") {

var exp = "1" + Array(length + 1).join("0");
var decPart = create(bigInt(parts[1]), bigInt(exp));
var decPart = reduce(bigInt(parts[1]), bigInt(exp));
intPart = intPart.add(decPart);

@@ -224,21 +233,20 @@ if (parts[0][0] === '-') intPart = intPart.negate();

}
return create(bigInt(n));
return new BigRational(bigInt(n), bigInt[1]);
}
function parse(a, b) {
if(!a) {
return create(bigInt(0));
return new BigRational(bigInt(0), bigInt[1]);
}
if(b) {
return create(bigInt(a), bigInt(b));
return reduce(bigInt(a), bigInt(b));
}
if(typeof a === "object") {
if(a.instanceofBigInt) {
return create(a);
}
return a;
if (bigInt.isInstance(a)) {
return new BigRational(a, bigInt[1]);
}
if (a instanceof BigRational) return a;
var num;
var denom;
var text = a + "";
var text = String(a);
var texts = text.split("/");

@@ -262,5 +270,5 @@ if(texts.length > 2) {

denom = bigInt(texts[1]);
return create(num, denom).reduce();
return reduce(num, denom);
}
return create(bigInt(texts[0]), bigInt(texts[1]));
return reduce(bigInt(texts[0]), bigInt(texts[1]));
}

@@ -267,0 +275,0 @@ return parseDecimal(text);

@@ -1,1 +0,1 @@

var bigRat=function(){function e(t,n){return n.equals(0)?t:e(n,t.mod(n))}function t(t,n){return t.times(n).divide(e(t,n))}function n(i,o,u){o=o||bigInt(1),u=u||!1;var a={numerator:i,denominator:o,num:i,denom:o,reduce:function(){var t=e(a.num,a.denom),r=a.num.divide(t),i=a.denom.divide(t);i.lesser(0)&&(r=r.times(-1),i=i.times(-1));if(i.equals(0))throw"Denominator cannot be 0.";return n(r,i,!0)},abs:function(){return a.isPositive()?a:a.negate()},multiply:function(e,t){return e=r(e,t),n(a.num.times(e.num),a.denom.times(e.denom))},times:function(e,t){return a.multiply(e,t)},divide:function(e,t){return e=r(e,t),n(a.num.times(e.denom),a.denom.times(e.num))},over:function(e,t){return a.divide(e,t)},mod:function(e,t){var e=r(e,t);return a.minus(e.times(a.over(e).floor()))},add:function(e,i){e=r(e,i);var s=t(a.denom,e.denom),o=s.divide(a.denom),u=s.divide(e.denom);return o=a.num.times(o),u=e.num.times(u),n(o.add(u),s)},plus:function(e,t){return a.add(e,t)},negate:function(){var e=bigInt.zero.minus(a.num);return n(e,a.denom)},subtract:function(e,t){return e=r(e,t),a.add(e.negate())},minus:function(e,t){return a.subtract(e,t)},isPositive:function(){return a.num.isPositive()},isNegative:function(){return!a.isPositive()},isZero:function(){return a.equals(0,1)},compare:function(e,t){e=r(e,t);if(a.num.equals(e.num)&&a.denom.equals(e.denom))return 0;var n=a.denom.times(e.denom),i=n.greater(0)?1:-1;return a.num.times(e.denom).greater(e.num.times(a.denom))?i:-i},equals:function(e,t){return a.compare(e,t)===0},notEquals:function(e,t){return!a.equals(e,t)},lesser:function(e,t){return a.compare(e,t)<0},lesserOrEquals:function(e,t){return a.compare(e,t)<=0},greater:function(e,t){return a.compare(e,t)>0},greaterOrEquals:function(e,t){return a.compare(e,t)>=0},floor:function(e){var t=a.num.over(a.denom);return e?t:n(t)},ceil:function(e){var t=a.num.divmod(a.denom),r;return r=t.quotient,t.remainder.notEquals(0)&&(r=r.add(1)),e?r:n(r)},round:function(e){return a.add(1,2).floor(e)},toString:function(){var e=a.reduce();return e.num.toString()+"/"+e.denom.toString()},valueOf:function(){return a.num/a.denom},toDecimal:function(e){e=e||10;var t=a.num.divmod(a.denom),n=t.quotient.toString(),r=s(t.remainder,a.denom),i="";while(i.length<=e){var o;for(o=0;o<=10;o++)if(s(i+o,"1"+Array(i.length+2).join("0")).greater(r)){o--;break}i+=o}while(i.slice(-1)==="0")i=i.slice(0,-1);return i===""?n:n+"."+i}};return u?a:a.reduce()}function r(e,t){return s(e,t)}function i(e){var t=e.split("e");if(t.length>2)throw new Error("Invalid input: too many 'e' tokens");if(t.length>1){var r=!0;t[1][0]==="-"&&(t[1]=t[1].slice(1),r=!1),t[1][0]==="+"&&(t[1]=t[1].slice(1));var s=i(t[0]),o=n(bigInt(10).pow(t[1]));return r?s.times(o):s.over(o)}t=e.split(".");if(t.length>2)throw new Error("Invalid input: too many '.' tokens");if(t.length>1){var u=n(bigInt(t[0])),a=t[1].length;while(t[1][0]==="0")t[1]=t[1].slice(1);var f="1"+Array(a+1).join("0"),l=n(bigInt(t[1]),bigInt(f));return u=u.add(l),t[0][0]==="-"&&(u=u.negate()),u}return n(bigInt(e))}function s(e,t){if(!e)return n(bigInt(0));if(t)return n(bigInt(e),bigInt(t));if(typeof e=="object")return e.instanceofBigInt?n(e):e;var r,s,o=e+"",u=o.split("/");if(u.length>2)throw new Error("Invalid input: too many '/' tokens");if(u.length>1){var a=u[0].split("_");if(a.length>2)throw new Error("Invalid input: too many '_' tokens");if(a.length>1){var f=a[0][0]!=="-";return r=bigInt(a[0]).times(u[1]),f?r=r.add(a[1]):r=r.subtract(a[1]),s=bigInt(u[1]),n(r,s).reduce()}return n(bigInt(u[0]),bigInt(u[1]))}return i(o)}return typeof require!="undefined"&&(bigInt=require("big-integer")),s.zero=s(0),s.one=s(1),s.minusOne=s(-1),s}();typeof module!="undefined"&&module.hasOwnProperty("exports")&&(module.exports=bigRat);
var bigRat=function(){function e(e,t){if(t.isZero())throw"Denominator cannot be 0.";this.numerator=this.num=e,this.denominator=this.denom=t}function r(n,r){var i=t(n,r),s=n.over(i),o=r.over(i);return o.isNegative()?new e(s.negate(),o.negate()):new e(s,o)}function i(e,t){return o(e,t)}function s(t){var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid input: too many 'e' tokens");if(n.length>1){var i=!0;n[1][0]==="-"&&(n[1]=n[1].slice(1),i=!1),n[1][0]==="+"&&(n[1]=n[1].slice(1));var o=s(n[0]),u=new e(bigInt(10).pow(n[1]),bigInt[1]);return i?o.times(u):o.over(u)}n=t.split(".");if(n.length>2)throw new Error("Invalid input: too many '.' tokens");if(n.length>1){var a=new e(bigInt(n[0]),bigInt[1]),f=n[1].length;while(n[1][0]==="0")n[1]=n[1].slice(1);var l="1"+Array(f+1).join("0"),c=r(bigInt(n[1]),bigInt(l));return a=a.add(c),n[0][0]==="-"&&(a=a.negate()),a}return new e(bigInt(t),bigInt[1])}function o(t,n){if(!t)return new e(bigInt(0),bigInt[1]);if(n)return r(bigInt(t),bigInt(n));if(bigInt.isInstance(t))return new e(t,bigInt[1]);if(t instanceof e)return t;var i,o,u=String(t),a=u.split("/");if(a.length>2)throw new Error("Invalid input: too many '/' tokens");if(a.length>1){var f=a[0].split("_");if(f.length>2)throw new Error("Invalid input: too many '_' tokens");if(f.length>1){var l=f[0][0]!=="-";return i=bigInt(f[0]).times(a[1]),l?i=i.add(f[1]):i=i.subtract(f[1]),o=bigInt(a[1]),r(i,o)}return r(bigInt(a[0]),bigInt(a[1]))}return s(u)}typeof require=="function"&&(bigInt=require("big-integer"));var t=bigInt.gcd,n=bigInt.lcm;return e.prototype.add=function(e,t){var s=i(e,t),o=n(this.denom,s.denom),u=o.divide(this.denom),a=o.divide(s.denom);return u=this.num.times(u),a=s.num.times(a),r(u.add(a),o)},e.prototype.plus=e.prototype.add,e.prototype.subtract=function(e,t){var n=i(e,t);return this.add(n.negate())},e.prototype.minus=e.prototype.subtract,e.prototype.multiply=function(e,t){var n=i(e,t);return r(this.num.times(n.num),this.denom.times(n.denom))},e.prototype.times=e.prototype.multiply,e.prototype.divide=function(e,t){var n=i(e,t);return r(this.num.times(n.denom),this.denom.times(n.num))},e.prototype.over=e.prototype.divide,e.prototype.reciprocate=function(){return new e(this.denom,this.num)},e.prototype.mod=function(e,t){var n=i(e,t);return this.minus(n.times(this.over(n).floor()))},e.prototype.floor=function(t){var n=this.num.divmod(this.denom),r;return n.remainder.isZero()||!n.quotient.sign?r=n.quotient:r=n.quotient.prev(),t?r:new e(r,bigInt[1])},e.prototype.ceil=function(t){var n=this.num.divmod(this.denom),r;return n.remainder.isZero()||n.quotient.sign?r=n.quotient:r=n.quotient.next(),t?r:new e(r,bigInt[1])},e.prototype.round=function(e){return this.add(1,2).floor(e)},e.prototype.compareAbs=function(e,t){var n=i(e,t);return this.denom.equals(n.denom)?this.num.compareAbs(n.num):this.num.times(n.denom).compareAbs(n.num.times(this.denom))},e.prototype.compare=function(e,t){var n=i(e,t);if(this.denom.equals(n.denom))return this.num.compare(n.num);var r=this.denom.sign===n.denom.sign?1:-1;return r*this.num.times(n.denom).compare(n.num.times(this.denom))},e.prototype.compareTo=e.prototype.compare,e.prototype.equals=function(e,t){return this.compare(e,t)===0},e.prototype.eq=e.prototype.equals,e.prototype.notEquals=function(e,t){return this.compare(e,t)!==0},e.prototype.neq=e.prototype.notEquals,e.prototype.lesser=function(e,t){return this.compare(e,t)<0},e.prototype.lt=e.prototype.lesser,e.prototype.lesserOrEquals=function(e,t){return this.compare(e,t)<=0},e.prototype.leq=e.prototype.lesserOrEquals,e.prototype.greater=function(e,t){return this.compare(e,t)>0},e.prototype.gt=e.prototype.greater,e.prototype.greaterOrEquals=function(e,t){return this.compare(e,t)>=0},e.prototype.geq=e.prototype.greaterOrEquals,e.prototype.abs=function(){return this.isPositive()?this:this.negate()},e.prototype.negate=function(){return this.denom.sign?new e(this.num,this.denom.negate()):new e(this.num.negate(),this.denom)},e.prototype.isNegative=function(){return this.num.sign!==this.denom.sign},e.prototype.isPositive=function(){return this.num.sign===this.denom.sign},e.prototype.isZero=function(){return this.num.isZero()},e.prototype.toDecimal=function(e){e=e||10;var t=this.num.divmod(this.denom),n=t.quotient.toString(),r=o(t.remainder.abs(),this.denom),i="";while(i.length<=e){var s;for(s=0;s<=10;s++)if(o(i+s,"1"+Array(i.length+2).join("0")).greater(r)){s--;break}i+=s}while(i.slice(-1)==="0")i=i.slice(0,-1);return i===""?n:n+"."+i},e.prototype.toString=function(){return String(this.num)+"/"+String(this.denom)},e.prototype.valueOf=function(){return this.num/this.denom},o.zero=o(0),o.one=o(1),o.minusOne=o(-1),o}();typeof module!="undefined"&&module.hasOwnProperty("exports")&&(module.exports=bigRat);
{
"name": "big-rational",
"version": "0.9.8",
"version": "0.9.9",
"author": "Peter Olson <peter.e.c.olson+npm@gmail.com>",

@@ -26,3 +26,3 @@ "description": "An arbitrary length rational number library for Javascript",

"dependencies" : {
"big-integer" : "1.3.x"
"big-integer" : "1.4.x"
},

@@ -29,0 +29,0 @@ "license": "WTFPL",

@@ -0,0 +0,0 @@ <!DOCTYPE html>