List of usage examples for java.math BigDecimal BigDecimal
public BigDecimal(long val)
From source file:Main.java
public static String str2Bi(String d) { BigDecimal bigDecimal = new BigDecimal(d); bigDecimal = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); return bigDecimal.toString(); }
From source file:Main.java
public static double mul(String d1, String d2) { BigDecimal b1 = new BigDecimal(d1); BigDecimal b2 = new BigDecimal(d2); return b1.multiply(b2).doubleValue(); }
From source file:Main.java
public static double add(String d1, String d2) { BigDecimal b1 = new BigDecimal(d1); BigDecimal b2 = new BigDecimal(d2); return b1.add(b2).doubleValue(); }
From source file:Main.java
public static double sub(String d1, String d2) { BigDecimal b1 = new BigDecimal(d1); BigDecimal b2 = new BigDecimal(d2); return b1.subtract(b2).doubleValue(); }
From source file:Main.java
public static double mul(double d1, double d2) { BigDecimal b1 = new BigDecimal(Double.toString(d1)); BigDecimal b2 = new BigDecimal(Double.toString(d2)); return b1.multiply(b2).doubleValue(); }
From source file:Main.java
public static double add(double v1, double v2) { BigDecimal a = new BigDecimal(v1); BigDecimal b = new BigDecimal(v2); BigDecimal c = a.add(b);/*from w ww . jav a2s .c o m*/ return c.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); }
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 String convertToNormal(String str) { BigDecimal db = new BigDecimal(str); return db.toPlainString(); }
From source file:Main.java
public static Double mul(Double v1, Double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); double m = b1.multiply(b2).doubleValue(); return m;// w w w .j a v a 2 s . co m }
From source file:Main.java
public static float subFloat(Float v1, Float v2) { BigDecimal b1 = new BigDecimal(Float.toString(v1)); BigDecimal b2 = new BigDecimal(Float.toString(v2)); return b1.subtract(b2).floatValue(); }