Skip to content

Instantly share code, notes, and snippets.

@DeppWang
Last active May 7, 2019 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeppWang/77fe719e8f5ba7fbed3aee54c5a4c71e to your computer and use it in GitHub Desktop.
Save DeppWang/77fe719e8f5ba7fbed3aee54c5a4c71e to your computer and use it in GitHub Desktop.
Double数值默认下舍入保留一位小数,直接舍弃掉1位小数后的值
private Double roundDownDouble(Double value) {
BigDecimal b = new BigDecimal(String.valueOf(value));//BigDecimal(String val)可控,BigDecimal(double val)不可预测。(BigDecimal:不可变的,任意精度带符号的十进制数)
return b.setScale(1, BigDecimal.ROUND_DOWN).doubleValue();//下舍入
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment