private int combineReal(double val,byte[] buf,int off,int len,byte[] mant,int lmant,int shift){
  double pos=Math.abs(val);
  boolean simple=false;
  int minSize;
  int maxSize;
  if (pos >= ByteFormatter.DEFAULT_SIMPLE_MIN && pos <= ByteFormatter.DEFAULT_SIMPLE_MAX) {
    simple=true;
  }
  int exp=lmant - shift - 1;
  int lexp=0;
  if (!simple) {
    lexp=format(exp,this.tbuf2,0,ByteFormatter.TEMP_BUFFER_SIZE);
    minSize=lexp + 2;
    maxSize=lexp + lmant + 2;
  }
 else {
    if (exp >= 0) {
      minSize=exp + 1;
      int i;
      for (i=0; i < lmant && i <= exp; i++) {
        if (mant[i] != (byte)'9') {
          break;
        }
      }
      if (i > exp && i < lmant && mant[i] >= (byte)'5') {
        minSize++;
      }
      maxSize=lmant + 1;
      if (maxSize <= minSize) {
        maxSize=minSize + 1;
      }
    }
 else {
      minSize=2;
      maxSize=1 + Math.abs(exp) + lmant;
    }
  }
  if (val < 0) {
    minSize++;
  }
  if (minSize > len || minSize > buf.length - off) {
    truncationFiller(buf,off,len);
    return off + len;
  }
  if (val < 0) {
    buf[off]=(byte)'-';
    off++;
    len--;
  }
  if (simple) {
    return Math.abs(mantissa(mant,lmant,exp,simple,buf,off,len));
  }
 else {
    off=mantissa(mant,lmant,0,simple,buf,off,len - lexp - 1);
    if (off < 0) {
      off=-off;
      len-=off;
      if (exp == MAXIMUM_SINGLE_DIGIT_INTEGER || exp == MAXIMUM_TWO_DIGIT_INTEGER) {
        if (off + len == minSize) {
          truncationFiller(buf,off,len);
          return off + len;
        }
 else {
          off--;
        }
      }
      exp++;
      lexp=format(exp,this.tbuf2,0,ByteFormatter.TEMP_BUFFER_SIZE);
    }
    buf[off]=(byte)'E';
    off++;
    System.arraycopy(this.tbuf2,0,buf,off,lexp);
    return off + lexp;
  }
}

private int combineReal ( double val , byte [ ] buf , int off , int len , byte [ ] mant , int lmant , int shift ) { double pos = Math . abs ( val ) ; boolean simple = false ; int minSize ; int maxSize ; if ( pos >= ByteFormatter . DEFAULT_SIMPLE_MIN && pos <= ByteFormatter . DEFAULT_SIMPLE_MAX ) { simple = true ; } int exp = lmant - shift - 1 ; int lexp = 0 ; if ( ! simple ) { lexp = format ( exp , this . tbuf2 , 0 , ByteFormatter . TEMP_BUFFER_SIZE ) ; minSize = lexp + 2 ; maxSize = lexp + lmant + 2 ; } else { if ( exp >= 0 ) { minSize = exp + 1 ; int i ; for ( i = 0 ; i < lmant && i <= exp ; i ++ ) { if ( mant [ i ] != ( byte ) '9' ) { break ; } } if ( i > exp && i < lmant && mant [ i ] >= ( byte ) '5' ) { minSize ++ ; } maxSize = lmant + 1 ; if ( maxSize <= minSize ) { maxSize = minSize + 1 ; } } else { minSize = 2 ; maxSize = 1 + Math . abs ( exp ) + lmant ; } } if ( val < 0 ) { minSize ++ ; } if ( minSize > len || minSize > buf . length - off ) { truncationFiller ( buf , off , len ) ; return off + len ; } if ( val < 0 ) { buf [ off ] = ( byte ) '-' ; off ++ ; len -- ; } if ( simple ) { return Math . abs ( mantissa ( mant , lmant , exp , simple , buf , off , len ) ) ; } else { off = mantissa ( mant , lmant , 0 , simple , buf , off , len - lexp - 1 ) ; if ( off < 0 ) { off = - off ; len -= off ; if ( exp == MAXIMUM_SINGLE_DIGIT_INTEGER || exp == MAXIMUM_TWO_DIGIT_INTEGER ) { if ( off + len == minSize ) { truncationFiller ( buf , off , len ) ; return off + len ; } else { off -- ; } } exp ++ ; lexp = format ( exp , this . tbuf2 , 0 , ByteFormatter . TEMP_BUFFER_SIZE ) ; } buf [ off ] = ( byte ) 'E' ; off ++ ; System . arraycopy ( this . tbuf2 , 0 , buf , off , lexp ) ; return off + lexp ; } }
this method formats a double given a decimal mantissa and exponent information .
