lib/bigint.js
function(lDigits, rDigits) {
    var difference = [];

    // assert: lDigits.length >= rDigits.length
    
    var carry = 0, i;

    for (i = 0; i < rDigits.length; i += 1) {
        difference[i] = lDigits[i] - rDigits[i] + carry;

        if (difference[i] < 0) {
            difference[i] += 2;
            carry = -1;
        }
        else {
            carry = 0;
        }
    }

    for (; i < lDigits.length; i += 1) {
        difference[i] = lDigits[i] + carry;

        if (difference[i] < 0) {
            difference[i] += 2;
            carry = -1;
        }
        else {
            carry = 0;
        }
    }

    if (carry !== 0) {
        throw new Error('never goes here');
    }

    return difference;
}
function(lDigits, rDigits) {
    var difference = [];

    // assert: lDigits.length >= rDigits.length
    
    var carry = 0, i;

    for (i = 0; i < rDigits.length; i += 1) {
        difference[i] = lDigits[i] - rDigits[i] + carry;

        if (difference[i] < 0) {
            difference[i] += 2;
            carry = -1;
        }
        else {
            carry = 0;
        }
    }

    for (; i < lDigits.length; i += 1) {
        difference[i] = lDigits[i] + carry;

        if (difference[i] < 0) {
            difference[i] += 2;
            carry = -1;
        }
        else {
            carry = 0;
        }
    }

    if (carry !== 0) {
        throw new Error('never goes here');
    }

    return difference;
}
function ( lDigits , rDigits ) { var difference = [ ] ; // assert: lDigits.length >= rDigits.length var carry = 0 , i ; for ( i = 0 ; i < rDigits . length ; i += 1 ) { difference [ i ] = lDigits [ i ] - rDigits [ i ] + carry ; if ( difference [ i ] < 0 ) { difference [ i ] += 2 ; carry = - 1 ; } else { carry = 0 ; } } for ( ; i < lDigits . length ; i += 1 ) { difference [ i ] = lDigits [ i ] + carry ; if ( difference [ i ] < 0 ) { difference [ i ] += 2 ; carry = - 1 ; } else { carry = 0 ; } } if ( carry !== 0 ) { throw new Error ( 'never goes here' ) ; } return difference ; }
lDigits must represent number that is greater than number representated by rDigits.
lDigits must represent number that is greater than number representated by rDigits .