big-number.js
function BigNumber(initialNumber) {
        var index;

        if (!(this instanceof BigNumber)) {
            return new BigNumber(initialNumber);
        }

        this.number = [];
        this.sign = 1;
        this.rest = 0;

        // The initial number can be an array, string, number of another big number
        // e.g. array     : [3,2,1], ['+',3,2,1], ['-',3,2,1]
        //      number    : 312
        //      string    : '321', '+321', -321'
        //      BigNumber : BigNumber(321)
        // Every character except the first must be a digit

        if (!isValidType(initialNumber)) {
            this.number = errors['invalid'];
            return;
        }

        if (isArray(initialNumber)) {
            if (initialNumber.length && initialNumber[0] === '-' || initialNumber[0] === '+') {
                this.sign = initialNumber[0] === '+' ? 1 : -1;
                initialNumber.shift(0);
            }
            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(initialNumber[index]))
                    return;
            }
        } else {
            initialNumber = initialNumber.toString();
            if (initialNumber.charAt(0) === '-' || initialNumber.charAt(0) === '+') {
                this.sign = initialNumber.charAt(0) === '+' ? 1 : -1;
                initialNumber = initialNumber.substring(1);
            }

            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(parseInt(initialNumber.charAt(index), 10))) {
                    return;
                }
            }
        }
    }
function BigNumber(initialNumber) {
        var index;

        if (!(this instanceof BigNumber)) {
            return new BigNumber(initialNumber);
        }

        this.number = [];
        this.sign = 1;
        this.rest = 0;

        // The initial number can be an array, string, number of another big number
        // e.g. array     : [3,2,1], ['+',3,2,1], ['-',3,2,1]
        //      number    : 312
        //      string    : '321', '+321', -321'
        //      BigNumber : BigNumber(321)
        // Every character except the first must be a digit

        if (!isValidType(initialNumber)) {
            this.number = errors['invalid'];
            return;
        }

        if (isArray(initialNumber)) {
            if (initialNumber.length && initialNumber[0] === '-' || initialNumber[0] === '+') {
                this.sign = initialNumber[0] === '+' ? 1 : -1;
                initialNumber.shift(0);
            }
            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(initialNumber[index]))
                    return;
            }
        } else {
            initialNumber = initialNumber.toString();
            if (initialNumber.charAt(0) === '-' || initialNumber.charAt(0) === '+') {
                this.sign = initialNumber.charAt(0) === '+' ? 1 : -1;
                initialNumber = initialNumber.substring(1);
            }

            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(parseInt(initialNumber.charAt(index), 10))) {
                    return;
                }
            }
        }
    }
function BigNumber ( initialNumber ) { var index ; if ( ! ( this instanceof BigNumber ) ) { return new BigNumber ( initialNumber ) ; } this . number = [ ] ; this . sign = 1 ; this . rest = 0 ; // The initial number can be an array, string, number of another big number // e.g. array     : [3,2,1], ['+',3,2,1], ['-',3,2,1] //      number    : 312 //      string    : '321', '+321', -321' //      BigNumber : BigNumber(321) // Every character except the first must be a digit if ( ! isValidType ( initialNumber ) ) { this . number = errors [ 'invalid' ] ; return ; } if ( isArray ( initialNumber ) ) { if ( initialNumber . length && initialNumber [ 0 ] === '-' || initialNumber [ 0 ] === '+' ) { this . sign = initialNumber [ 0 ] === '+' ? 1 : - 1 ; initialNumber . shift ( 0 ) ; } for ( index = initialNumber . length - 1 ; index >= 0 ; index -- ) { if ( ! this . addDigit ( initialNumber [ index ] ) ) return ; } } else { initialNumber = initialNumber . toString ( ) ; if ( initialNumber . charAt ( 0 ) === '-' || initialNumber . charAt ( 0 ) === '+' ) { this . sign = initialNumber . charAt ( 0 ) === '+' ? 1 : - 1 ; initialNumber = initialNumber . substring ( 1 ) ; } for ( index = initialNumber . length - 1 ; index >= 0 ; index -- ) { if ( ! this . addDigit ( parseInt ( initialNumber . charAt ( index ) , 10 ) ) ) { return ; } } } }
Constructor function which creates a new BigNumber object from an integer, a string, an array or other BigNumber object
Constructor function which creates a new BigNumber object from an integer a string an array or other BigNumber object