if (c == Conversion.SCIENTIFIC) {
// Create a new FormattedFloatingDecimal with the desired
// precision.
int prec = (precision == -1 ? 6 : precision);
FormattedFloatingDecimal fd
= new FormattedFloatingDecimal(value, prec,
FormattedFloatingDecimal.Form.SCIENTIFIC);
char[] v = new char[MAX_FD_CHARS];
int len = fd.getChars(v);
char[] mant = addZeros(mantissa(v, len), prec);
// If the precision is zero and the '#' flag is set, add the
// requested decimal point.
if (f.contains(Flags.ALTERNATE) && (prec == 0))
mant = addDot(mant);
char[] exp = (value == 0.0)
? new char[] {'+','0','0'} : exponent(v, len);
int newW = width;
if (width != -1)
newW = adjustWidth(width - exp.length - 1, f, neg);
localizedMagnitude(sb, mant, f, newW, null);
sb.append(f.contains(Flags.UPPERCASE) ? 'E' : 'e');
Flags flags = f.dup().remove(Flags.GROUP);
char sign = exp[0];
assert(sign == '+' || sign == '-');
sb.append(sign);
char[] tmp = new char[exp.length - 1];
System.arraycopy(exp, 1, tmp, 0, exp.length - 1);
sb.append(localizedMagnitude(null, tmp, flags, -1, null));
} else if (c == Conversion.DECIMAL_FLOAT) {
// Create a new FormattedFloatingDecimal with the desired
// precision.
int prec = (precision == -1 ? 6 : precision);
FormattedFloatingDecimal fd
= new FormattedFloatingDecimal(value, prec,
FormattedFloatingDecimal.Form.DECIMAL_FLOAT);
// MAX_FD_CHARS + 1 (round?)
char[] v = new char[MAX_FD_CHARS + 1
+ Math.abs(fd.getExponent())];
int len = fd.getChars(v);
char[] mant = addZeros(mantissa(v, len), prec);
// If the precision is zero and the '#' flag is set, add the
// requested decimal point.
if (f.contains(Flags.ALTERNATE) && (prec == 0))
mant = addDot(mant);
int newW = width;
if (width != -1)
newW = adjustWidth(width, f, neg);
localizedMagnitude(sb, mant, f, newW, l);
} else if (c == Conversion.GENERAL) {
int prec = precision;
if (precision == -1)
prec = 6;
else if (precision == 0)
prec = 1;
FormattedFloatingDecimal fd
= new FormattedFloatingDecimal(value, prec,
FormattedFloatingDecimal.Form.GENERAL);
// MAX_FD_CHARS + 1 (round?)
char[] v = new char[MAX_FD_CHARS + 1
+ Math.abs(fd.getExponent())];
int len = fd.getChars(v);
char[] exp = exponent(v, len);
if (exp != null) {
prec -= 1;
} else {
prec = prec - (value == 0 ? 0 : fd.getExponentRounded()) - 1;
}
char[] mant = addZeros(mantissa(v, len), prec);
// If the precision is zero and the '#' flag is set, add the
// requested decimal point.