List of usage examples for java.math BigDecimal setScale
@Deprecated(since = "9") public BigDecimal setScale(int newScale, int roundingMode)
From source file:Main.java
public static double mul(double v1, double v2) { BigDecimal a = new BigDecimal(v1); BigDecimal b = new BigDecimal(v2); BigDecimal c = a.multiply(b); return c.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
public static Integer processCurreny(String value) { BigDecimal bd = new BigDecimal(value); bd.setScale(2, BigDecimal.ROUND_HALF_UP); bd = bd.multiply(new BigDecimal(100)); return bd.intValue(); }
From source file:Main.java
public static double byteCastMB(long number) { double n = number / 1024.0 / 1024.0; BigDecimal bd = new BigDecimal(n); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); }
From source file:Main.java
public static double changeDouble(double dbl, int count) { BigDecimal b = new BigDecimal(dbl); return b.setScale(count, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
public static double keepThreePlacesOfDecimal(double number) { BigDecimal b = new BigDecimal(number); return b.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
public static double retainDecimal(int decimalNumber, double value) { BigDecimal bg = new BigDecimal(value); return bg.setScale(decimalNumber, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
public static double round(double value, int places) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(places, RoundingMode.HALF_UP); return bd.doubleValue(); }
From source file:Main.java
public static double roundDouble(double value, int scale, int roundingMode) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(scale, roundingMode); double d = bd.doubleValue(); bd = null;//from w w w . j a va 2 s . co m return d; }
From source file:Main.java
public static BigDecimal redondear(double f, int scale) { String val = f + ""; BigDecimal big = new BigDecimal(val); big = big.setScale(scale, RoundingMode.HALF_UP); return big;/*from w ww . j a v a2s .c o m*/ }
From source file:Main.java
private 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(); }