test/java/util/Formatter/BasicDoubleObject.java
Print this page
rev 7490 : 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
Summary: For zero value ensure than an unpadded zero character is passed to Formatter.addZeros()
Reviewed-by: TBD
Contributed-by: Brian Burkhalter <brian.burkhalter@oracle.com>
@@ -1121,10 +1121,19 @@
+
+
+
+
+
+
+
+
+
//---------------------------------------------------------------------
// %f - float, double, Double, BigDecimal
//---------------------------------------------------------------------
test("%.3f", "3141592.654", mult(pi, 1000000.0));
test("%.3f", "-3141592.654", mult(pi, -1000000.0));
@@ -1166,10 +1175,17 @@
test("%.0g", "-1e-05", recip(create(-100000.0)));
test("%.0g", "1e+05", create(100000.0));
test("%.3G", "1.00E-05", recip(create(100000.0)));
test("%.3G", "-1.00E-05", recip(create(-100000.0)));
+ test("%.1g", "-0", -0.0);
+ test("%3.0g", " -0", -0.0);
+ test("%.1g", "0", 0.0);
+ test("%3.0g", " 0", 0.0);
+ test("%.1g", "0", +0.0);
+ test("%3.0g", " 0", +0.0);
+
test("%3.0g", "1e-06", 0.000001);
test("%3.0g", "1e-05", 0.00001);
test("%3.0g", "1e-05", 0.0000099);
test("%3.1g", "1e-05", 0.0000099);
test("%3.2g", "9.9e-06", 0.0000099);