File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
main/java/icu/easyj/core/util
test/java/icu/easyj/core/util Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ public abstract class NumberUtils {
31
31
*/
32
32
public static String convertScientificToNormal (String scientificNumberStr ) {
33
33
int indexE = scientificNumberStr .toUpperCase ().indexOf ("E" );
34
+ if (indexE < 0 ) {
35
+ return scientificNumberStr ;
36
+ }
34
37
35
38
int exponential = Integer .parseInt (scientificNumberStr .substring (indexE + 1 ));
36
39
@@ -65,12 +68,7 @@ public static String convertScientificToNormal(String scientificNumberStr) {
65
68
}
66
69
67
70
public static String doubleToString (Double d ) {
68
- String doubleStr = d .toString ();
69
- if (doubleStr .contains ("E" )) {
70
- return convertScientificToNormal (doubleStr );
71
- } else {
72
- return doubleStr ;
73
- }
71
+ return convertScientificToNormal (d .toString ());
74
72
}
75
73
76
74
}
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ public class NumberUtilsTest {
15
15
*/
16
16
@ Test
17
17
public void test_convertScientificToNormal () {
18
+ Assertions .assertEquals ("123456789" , NumberUtils .convertScientificToNormal ("123456789" ));
19
+
18
20
Assertions .assertEquals ("123456789" , NumberUtils .convertScientificToNormal ("1.23456789E8" ));
19
21
Assertions .assertEquals ("123456789.1" , NumberUtils .convertScientificToNormal ("1.234567891E8" ));
20
22
Assertions .assertEquals ("123456789.12" , NumberUtils .convertScientificToNormal ("1.2345678912E8" ));
You can’t perform that action at this time.
0 commit comments