Add MUtil.round()
This commit is contained in:
parent
5430af6567
commit
ee1f4cf9c9
@ -1,6 +1,8 @@
|
||||
package com.massivecraft.massivecore.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -1347,6 +1349,15 @@ public class MUtil
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static double round(double value, int places)
|
||||
{
|
||||
if (places < 0) throw new IllegalArgumentException();
|
||||
|
||||
BigDecimal bd = new BigDecimal(value);
|
||||
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
||||
return bd.doubleValue();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRACTION
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user