Changeset 38461 for lang/javascript/mathbigint
 Timestamp:
 09/12/10 02:13:45 (5 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

lang/javascript/mathbigint/trunk/bigint.js
r38460 r38461 1 1 /* 2 * $Id $2 * $Id: bigint.js,v 0.1 2010/09/11 17:07:30 dankogai Exp dankogai $ 3 3 */ 4 4 5 (function() {5 (function() { 6 6 7 7 // Original: http://www.onicos.com/staff/iz/amuse/javascript/expert/BigInt.txt … … 272 272 function bigint_add_internal(x, y, sign) { 273 273 var z, num, i, len; 274 sign = !!sign; ;274 sign = !!sign; 275 275 if (x.sign != sign) { 276 276 return sign ? bigint_sub_internal(y, x) … … 307 307 var z, zds, num, i, cmp = bigint_cmp(x, y), rev = 0; 308 308 if (cmp === 0) return bzero; 309 if (cmp < 310 z = 309 if (cmp < 0) { rev = 1; z = x; x = y; y = z; } // swap x y 310 z = x.clone(); 311 311 var zds = z.digits, xds = x.digits, yds = y.digits; 312 312 for (i = 0, num = 0; i < y.len; i++) { … … 522 522 523 523 BigInt.prototype = { 524 toString: _BigInt_toString,525 toStringBase: _BigInt_toStringBase,526 clone: _BigInt_clone,527 add: function(y){ return bigint_add(y, this) },528 sub: function(y){ return bigint_sub(this, y) },529 mul: function(y){ return bigint_mul(this, y) },530 div: function(y){ return bigint_div(this, y) },531 mod: function(y){ return bigint_mod(this, y) },532 cmp: function(y){ return bigint_cmp(this, y) },533 neg: function(y){ return bigint_neg(this)}524 toString: _BigInt_toString, 525 toStringBase: _BigInt_toStringBase, 526 clone: _BigInt_clone, 527 add: function(y) { return bigint_add(y, this) }, 528 sub: function(y) { return bigint_sub(this, y) }, 529 mul: function(y) { return bigint_mul(this, y) }, 530 div: function(y) { return bigint_div(this, y) }, 531 mod: function(y) { return bigint_mod(this, y) }, 532 cmp: function(y) { return bigint_cmp(this, y) }, 533 neg: function(y) { return bigint_neg(this) } 534 534 }; 535 535 536 536 Math.BigInt = BigInt; 537 bigint = function(a) { return bigint_from_any(a) };537 bigint = function(a) { return bigint_from_any(a) }; 538 538 539 539 })();