private static byte[] convertToBytes(int i){
  int size=(int)Math.floor(Math.log(i) / Math.log(10));
  if (i % 100 != 0) {
    size+=2;
  }
  if (i % 10 != 0) {
    size++;
  }
  if (i < 100) {
    size++;
    if (i < 10) {
      size++;
    }
  }
  size--;
  byte[] cache=new byte[size];
  size--;
  if (i < 100) {
    cache[0]=(byte)'0';
  }
  if (i % 10 != 0) {
    cache[size--]=bytes[i % 10];
  }
  if (i % 100 != 0) {
    cache[size--]=bytes[(i / 10) % 10];
    cache[size--]=(byte)'.';
  }
  size=(int)Math.floor(Math.log(i) / Math.log(10)) - 1;
  int add=0;
  while (add < size) {
    cache[add]=bytes[(i / (int)Math.pow(10,size - add + 1)) % 10];
    add++;
  }
  return cache;
}

private static byte [ ] convertToBytes ( int i ) { int size = ( int ) Math . floor ( Math . log ( i ) / Math . log ( 10 ) ) ; if ( i % 100 != 0 ) { size += 2 ; } if ( i % 10 != 0 ) { size ++ ; } if ( i < 100 ) { size ++ ; if ( i < 10 ) { size ++ ; } } size -- ; byte [ ] cache = new byte [ size ] ; size -- ; if ( i < 100 ) { cache [ 0 ] = ( byte ) '0' ; } if ( i % 10 != 0 ) { cache [ size -- ] = bytes [ i % 10 ] ; } if ( i % 100 != 0 ) { cache [ size -- ] = bytes [ ( i / 10 ) % 10 ] ; cache [ size -- ] = ( byte ) '.' ; } size = ( int ) Math . floor ( Math . log ( i ) / Math . log ( 10 ) ) - 1 ; int add = 0 ; while ( add < size ) { cache [ add ] = bytes [ ( i / ( int ) Math . pow ( 10 , size - add + 1 ) ) % 10 ] ; add ++ ; } return cache ; }
converts an double ( multiplied by 100 and cast to an int ) into an array of bytes .
