]> granicus.if.org Git - icu/commitdiff
ICU-13310 Fixing assertion failure in ScientificFormat.
authorShane Carr <shane@unicode.org>
Thu, 14 Sep 2017 00:16:56 +0000 (00:16 +0000)
committerShane Carr <shane@unicode.org>
Thu, 14 Sep 2017 00:16:56 +0000 (00:16 +0000)
X-SVN-Rev: 40410

icu4j/main/classes/core/src/com/ibm/icu/impl/number/formatters/ScientificFormat.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java

index c2e71c80cc0dce3b629c07e8575ff63db3884ab8..e7d17de46e4a980d3254498e3f39878e8c1fd0f3 100644 (file)
@@ -154,9 +154,9 @@ public class ScientificFormat extends Format.BeforeFormat implements Rounder.Mul
     if (_maxInt > _minInt && _minInt > 1) {
         _minInt = 1;
     }
-    minInt = _minInt < 0 ? 0 : _minInt >= 8 ? 1 : _minInt;
-    maxInt = _maxInt < _minInt ? _minInt : _maxInt >= 8 ? _minInt : _maxInt;
-    assert 0 <= minInt && minInt <= maxInt && maxInt < 8;
+    maxInt = _maxInt > 8 ? 8 : _maxInt < _minInt ? _minInt : _maxInt;
+    minInt = _minInt < 0 ? 0 : _minInt > maxInt ? maxInt : _minInt;
+    assert 0 <= minInt && minInt <= maxInt && maxInt <= 8;
 
     interval = maxInt < 1 ? 1 : maxInt;
     this.rounder = rounder;
index 23c699bb03c969b3580cb5f17d1437b56459d1c3..1b270b3044b41e7928618deeb40c6203224c7df7 100644 (file)
@@ -5237,6 +5237,13 @@ public class NumberFormatTest extends TestFmwk {
         assertEquals("Should ignore scientific minInt if maxInt>minInt", "1.23E-3", result);
     }
 
+    @Test
+    public void Test13310() {
+        assertEquals("Should not throw an assertion error",
+                "10000000.76E0",
+                new DecimalFormat("000000000.0#E0").format(10000000.76d));
+    }
+
     @Test
     public void testPercentZero() {
         DecimalFormat df = (DecimalFormat) NumberFormat.getPercentInstance();