public int format(int val,byte[] buf,int off,int len){
  if (val == Integer.MIN_VALUE) {
    if (len > ByteFormatter.NUMBER_BASE) {
      return format("-2147483648",buf,off,len);
    }
 else {
      truncationFiller(buf,off,len);
      return off + len;
    }
  }
  int pos=Math.abs(val);
  int ndig=1;
  int dmax=ByteFormatter.NUMBER_BASE;
  while (ndig < ByteFormatter.NUMBER_BASE && pos >= dmax) {
    ndig++;
    dmax*=ByteFormatter.NUMBER_BASE;
  }
  if (val < 0) {
    ndig++;
  }
  if (ndig > len || ndig > buf.length - off) {
    truncationFiller(buf,off,len);
    return off + len;
  }
  off+=ndig;
  int xoff=off - 1;
  do {
    buf[xoff]=ByteFormatter.DIGITS[pos % ByteFormatter.NUMBER_BASE];
    xoff--;
    pos/=ByteFormatter.NUMBER_BASE;
  }
 while (pos > 0);
  if (val < 0) {
    buf[xoff]=(byte)'-';
  }
  return off;
}

public int format ( int val , byte [ ] buf , int off , int len ) { if ( val == Integer . MIN_VALUE ) { if ( len > ByteFormatter . NUMBER_BASE ) { return format ( "-2147483648" , buf , off , len ) ; } else { truncationFiller ( buf , off , len ) ; return off + len ; } } int pos = Math . abs ( val ) ; int ndig = 1 ; int dmax = ByteFormatter . NUMBER_BASE ; while ( ndig < ByteFormatter . NUMBER_BASE && pos >= dmax ) { ndig ++ ; dmax *= ByteFormatter . NUMBER_BASE ; } if ( val < 0 ) { ndig ++ ; } if ( ndig > len || ndig > buf . length - off ) { truncationFiller ( buf , off , len ) ; return off + len ; } off += ndig ; int xoff = off - 1 ; do { buf [ xoff ] = ByteFormatter . DIGITS [ pos % ByteFormatter . NUMBER_BASE ] ; xoff -- ; pos /= ByteFormatter . NUMBER_BASE ; } while ( pos > 0 ) ; if ( val < 0 ) { buf [ xoff ] = ( byte ) '-' ; } return off ; }
format an int into an existing array .
