public FormatReal(final int in,final int iff){
  if (in < 0) {
    throw new IllegalArgumentException("leading digits is negative:" + in);
  }
  if (iff < 0) {
    throw new IllegalArgumentException("trailing digits is negative:" + iff);
  }
  mLength=1 + in + iff;
  mPadding=new char[mLength];
  for (int i=0; i < mLength; i++) {
    mPadding[i]=' ';
  }
  final StringBuilder formatpos=new StringBuilder();
  final StringBuilder formatneg=new StringBuilder();
  formatpos.append("#");
  formatneg.append("-");
  for (int i=2; i < in; i++) {
    formatpos.append("#");
    formatneg.append("#");
  }
  formatpos.append("0.");
  formatneg.append("0.");
  for (int i=0; i < iff; i++) {
    formatpos.append("0");
    formatneg.append("0");
  }
  final String format=formatpos.toString() + ";" + formatneg.toString();
  mLocalFormat=new DecimalFormat(format);
}

public FormatReal ( final int in , final int iff ) { if ( in < 0 ) { throw new IllegalArgumentException ( "leading digits is negative:" + in ) ; } if ( iff < 0 ) { throw new IllegalArgumentException ( "trailing digits is negative:" + iff ) ; } mLength = 1 + in + iff ; mPadding = new char [ mLength ] ; for ( int i = 0 ; i < mLength ; i ++ ) { mPadding [ i ] = ' ' ; } final StringBuilder formatpos = new StringBuilder ( ) ; final StringBuilder formatneg = new StringBuilder ( ) ; formatpos . append ( "#" ) ; formatneg . append ( "-" ) ; for ( int i = 2 ; i < in ; i ++ ) { formatpos . append ( "#" ) ; formatneg . append ( "#" ) ; } formatpos . append ( "0." ) ; formatneg . append ( "0." ) ; for ( int i = 0 ; i < iff ; i ++ ) { formatpos . append ( "0" ) ; formatneg . append ( "0" ) ; } final String format = formatpos . toString ( ) + ";" + formatneg . toString ( ) ; mLocalFormat = new DecimalFormat ( format ) ; }
construct a format for a real .
