ViewPager 指针四舍五入取整
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
@ -41,4 +42,13 @@ public class RandomUtils {
|
||||
return random.nextInt(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 四舍五入取整
|
||||
* @return
|
||||
*/
|
||||
public static int getInt(double d) {
|
||||
BigDecimal bigDecimal = new BigDecimal(d).setScale(0, BigDecimal.ROUND_HALF_UP);
|
||||
return bigDecimal.intValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user