1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| package com.moral.monitor.util;
|
| import java.math.BigDecimal;
|
| /**
| * Created by a on 2017/7/20.
| */
| public class Round {
|
| public static double digit(double num, int digit) {
| BigDecimal y = new BigDecimal(num);
| double b = y.setScale(digit, BigDecimal.ROUND_HALF_UP).doubleValue();
| double c = b - (int) b;
| if (c == 0) {
| return b;
| } else {
| return b;
| }
| }
| }
|
|