--- a/jdk/src/share/classes/java/util/Formatter.java Mon Jun 24 16:21:32 2013 -0700
+++ b/jdk/src/share/classes/java/util/Formatter.java Mon Jun 24 14:17:14 2013 -0700
@@ -3297,18 +3297,29 @@
else if (precision == 0)
prec = 1;
- FormattedFloatingDecimal fd
+ char[] exp;
+ char[] mant;
+ int expRounded;
+ if (value == 0.0) {
+ exp = null;
+ mant = new char[] {'0'};
+ expRounded = 0;
+ } else {
+ FormattedFloatingDecimal fd
= FormattedFloatingDecimal.valueOf(value, prec,
FormattedFloatingDecimal.Form.GENERAL);
-
- char[] exp = fd.getExponent();
+ exp = fd.getExponent();
+ mant = fd.getMantissa();
+ expRounded = fd.getExponentRounded();
+ }
+
if (exp != null) {
prec -= 1;
} else {
- prec = prec - (value == 0 ? 0 : fd.getExponentRounded()) - 1;
+ prec -= expRounded + 1;
}
- char[] mant = addZeros(fd.getMantissa(), prec);
+ mant = addZeros(mant, prec);
// If the precision is zero and the '#' flag is set, add the
// requested decimal point.
if (f.contains(Flags.ALTERNATE) && (prec == 0))