Show
Ignore:
Timestamp:
09/12/10 02:13:45 (4 years ago)
Author:
dankogai
Message:

VERSION 0.01

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/math-bigint/trunk/bigint.js

    r38460 r38461  
    11/* 
    2  * $Id$ 
     2 * $Id: bigint.js,v 0.1 2010/09/11 17:07:30 dankogai Exp dankogai $ 
    33 */ 
    44 
    5 (function(){ 
     5(function() { 
    66 
    77// Original: http://www.onicos.com/staff/iz/amuse/javascript/expert/BigInt.txt 
     
    272272function bigint_add_internal(x, y, sign) { 
    273273    var z, num, i, len; 
    274     sign = !!sign; ; 
     274    sign = !!sign; 
    275275    if (x.sign != sign) { 
    276276        return sign ? bigint_sub_internal(y, x) 
     
    307307    var z, zds, num, i, cmp = bigint_cmp(x, y), rev = 0; 
    308308    if (cmp === 0) return bzero; 
    309     if (cmp <   0) { rev = 1; z = x; x = y; y = z; } // swap x y 
    310     z =  x.clone(); 
     309    if (cmp < 0) { rev = 1; z = x; x = y; y = z; } // swap x y 
     310    z = x.clone(); 
    311311    var zds = z.digits, xds = x.digits, yds = y.digits; 
    312312    for (i = 0, num = 0; i < y.len; i++) { 
     
    522522 
    523523BigInt.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) } 
    534534}; 
    535535 
    536536Math.BigInt = BigInt; 
    537 bigint = function(a){ return bigint_from_any(a) }; 
     537bigint = function(a) { return bigint_from_any(a) }; 
    538538 
    539539})();