This commit is contained in:
xiangwb
2018-07-06 20:33:01 +08:00
parent a0e69844fe
commit 1a48766b99
3 changed files with 6 additions and 17 deletions
@@ -9,7 +9,7 @@ import java.math.BigDecimal;
* 说明: 数字工具类
*/
public class DecimalUtil {
private static final int DEF_DIV_SCALE = 10;
private static final int DEF_DIV_SCALE = 5;
/**
* 两个Double数相加
@@ -87,7 +87,7 @@ public class DecimalUtil {
* @param scale 小数位
* @return
*/
public static Double formate(Double v1, int scale) {
public static Double format(Double v1, int scale) {
BigDecimal bg = new BigDecimal(v1);
return bg.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
@@ -117,12 +117,12 @@ public class DecimalUtil {
}
public static void main(String[] args) {
Double div = div((double) 9, (double) 8, 2);
Double div = div((9.0), 8.0, 2);
System.out.println(div);
div = formate(div, 1);
div = format(div, 1);
System.out.println(div);
Double formate = formate(6.2, 1);
System.out.println(formate);
Double format = format(6.2, 1);
System.out.println(format);
Double d = 1.11;
int i = d.intValue();
System.out.println(i);
@@ -1 +0,0 @@
var basePath = "http://127.0.0.1:8080/";
@@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome to the world</title>
</head>
<body>
<h2>Hello World!</h2>
</body>
</html>