test/java/util/Formatter/BasicFloatObject.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>
@@ -1137,10 +1137,19 @@
+
+
+
+
+
+
+
+
+
//---------------------------------------------------------------------
// %g
//
// Floating-point conversions applicable to float, double, and
// BigDecimal.
@@ -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);