bignumber.js
function multiply(x, k, base) {
        var m, temp, xlo, xhi,
          carry = 0,
          i = x.length,
          klo = k % SQRT_BASE,
          khi = k / SQRT_BASE | 0;

        for (x = x.slice(); i--;) {
          xlo = x[i] % SQRT_BASE;
          xhi = x[i] / SQRT_BASE | 0;
          m = khi * xlo + xhi * klo;
          temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
          carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
          x[i] = temp % base;
        }

        if (carry) x = [carry].concat(x);

        return x;
      }
function multiply(x, k, base) {
        var m, temp, xlo, xhi,
          carry = 0,
          i = x.length,
          klo = k % SQRT_BASE,
          khi = k / SQRT_BASE | 0;

        for (x = x.slice(); i--;) {
          xlo = x[i] % SQRT_BASE;
          xhi = x[i] / SQRT_BASE | 0;
          m = khi * xlo + xhi * klo;
          temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
          carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
          x[i] = temp % base;
        }

        if (carry) x = [carry].concat(x);

        return x;
      }
function multiply ( x , k , base ) { var m , temp , xlo , xhi , carry = 0 , i = x . length , klo = k % SQRT_BASE , khi = k / SQRT_BASE | 0 ; for ( x = x . slice ( ) ; i -- ; ) { xlo = x [ i ] % SQRT_BASE ; xhi = x [ i ] / SQRT_BASE | 0 ; m = khi * xlo + xhi * klo ; temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry ; carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi ; x [ i ] = temp % base ; } if ( carry ) x = [ carry ] . concat ( x ) ; return x ; }
Assume non-zero x and k.
Assume non - zero x and k .