private static int[] add(int[] x,int[] y){
  if (x.length < y.length) {
    int[] tmp=x;
    x=y;
    y=tmp;
  }
  int xIndex=x.length;
  int yIndex=y.length;
  int result[]=new int[xIndex];
  long sum=0;
  if (yIndex == 1) {
    sum=(x[--xIndex] & LONG_MASK) + (y[0] & LONG_MASK);
    result[xIndex]=(int)sum;
  }
 else {
    while (yIndex > 0) {
      sum=(x[--xIndex] & LONG_MASK) + (y[--yIndex] & LONG_MASK) + (sum >>> 32);
      result[xIndex]=(int)sum;
    }
  }
  boolean carry=(sum >>> 32 != 0);
  while (xIndex > 0 && carry)   carry=((result[--xIndex]=x[xIndex] + 1) == 0);
  while (xIndex > 0)   result[--xIndex]=x[xIndex];
  if (carry) {
    int bigger[]=new int[result.length + 1];
    System.arraycopy(result,0,bigger,1,result.length);
    bigger[0]=0x01;
    return bigger;
  }
  return result;
}

private static int [ ] add ( int [ ] x , int [ ] y ) { if ( x . length < y . length ) { int [ ] tmp = x ; x = y ; y = tmp ; } int xIndex = x . length ; int yIndex = y . length ; int result [ ] = new int [ xIndex ] ; long sum = 0 ; if ( yIndex == 1 ) { sum = ( x [ -- xIndex ] & LONG_MASK ) + ( y [ 0 ] & LONG_MASK ) ; result [ xIndex ] = ( int ) sum ; } else { while ( yIndex > 0 ) { sum = ( x [ -- xIndex ] & LONG_MASK ) + ( y [ -- yIndex ] & LONG_MASK ) + ( sum > > > 32 ) ; result [ xIndex ] = ( int ) sum ; } } boolean carry = ( sum > > > 32 != 0 ) ; while ( xIndex > 0 && carry ) carry = ( ( result [ -- xIndex ] = x [ xIndex ] + 1 ) == 0 ) ; while ( xIndex > 0 ) result [ -- xIndex ] = x [ xIndex ] ; if ( carry ) { int bigger [ ] = new int [ result . length + 1 ] ; System . arraycopy ( result , 0 , bigger , 1 , result . length ) ; bigger [ 0 ] = 0x01 ; return bigger ; } return result ; }
adds the contents of the int arrays x and y . this method allocates a new int array to hold the answer and returns a reference to that array .
