Skip to content

Commit

Permalink
fix prefer to BigDecimal.valueOf for float and double
Browse files Browse the repository at this point in the history
  • Loading branch information
yanxutao89 authored and lizongbo committed Jun 21, 2024
1 parent 963b193 commit 67cee52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,7 @@ public void printParameter(Object param) {
}

if (param instanceof Double) {
param = new BigDecimal((double) param);
param = BigDecimal.valueOf((double) param);
}
if (param instanceof BigDecimal) { // 不需要科学计数法输出
print0(((BigDecimal) param).toPlainString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1515,11 +1515,11 @@ public static BigDecimal castToDecimal(Object val) {
}

if (val instanceof Float) {
return new BigDecimal((Float) val);
return BigDecimal.valueOf((Float) val);
}

if (val instanceof Double) {
return new BigDecimal((Double) val);
return BigDecimal.valueOf((Double) val);
}

return BigDecimal.valueOf(((Number) val).longValue());
Expand Down

0 comments on commit 67cee52

Please sign in to comment.