Unverified 提交 2a3b8cfb authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #826 from musius/fix/issue115

Fix 'String index out of range' for numbers with a very little scale in 'to_char'. Issue 115
......@@ -338,7 +338,7 @@ public class ToChar {
}
private static String zeroesAfterDecimalSeparator(BigDecimal number) {
final String numberStr = number.toString();
final String numberStr = number.toPlainString();
final int idx = numberStr.indexOf('.');
if (idx < 0) {
return "";
......
......@@ -1933,6 +1933,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
final String twoDecimals = "0" + decimalSeparator + "00";
assertResult(oneDecimal, stat, "select to_char(0, 'FM0D099') from dual;");
assertResult(twoDecimals, stat, "select to_char(0., 'FM0D009') from dual;");
assertResult("0.000000000", stat, "select to_char(0.000000000, 'FM0D999999999') from dual;");
assertResult("0" + decimalSeparator, stat, "select to_char(0, 'FM0D9') from dual;");
assertResult(oneDecimal, stat, "select to_char(0.0, 'FM0D099') from dual;");
assertResult(twoDecimals, stat, "select to_char(0.00, 'FM0D009') from dual;");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论