提交 46983c43 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Code simplification

上级 ec5bedb4
...@@ -332,7 +332,9 @@ public class ToChar { ...@@ -332,7 +332,9 @@ public class ToChar {
private static String zeroesAfterDecimalSeparator(BigDecimal number) { private static String zeroesAfterDecimalSeparator(BigDecimal number) {
final String numberStr = number.toString(); final String numberStr = number.toString();
final int idx = numberStr.indexOf('.'); final int idx = numberStr.indexOf('.');
if (idx >= 0 ) { if (idx < 0) {
return "";
}
int i = idx + 1; int i = idx + 1;
boolean allZeroes = true; boolean allZeroes = true;
for (; i < numberStr.length(); i++) { for (; i < numberStr.length(); i++) {
...@@ -344,9 +346,6 @@ public class ToChar { ...@@ -344,9 +346,6 @@ public class ToChar {
final char[] zeroes = new char[allZeroes ? numberStr.length() - idx - 1: i - 1 - idx]; final char[] zeroes = new char[allZeroes ? numberStr.length() - idx - 1: i - 1 - idx];
Arrays.fill(zeroes, '0'); Arrays.fill(zeroes, '0');
return String.valueOf(zeroes); return String.valueOf(zeroes);
} else {
return "";
}
} }
private static void addSign(StringBuilder output, int signum, private static void addSign(StringBuilder output, int signum,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论