List of usage examples for java.math BigDecimal subtract
public BigDecimal subtract(BigDecimal subtrahend)
From source file:Main.java
public static double sub(float v1, float v2) { BigDecimal b1 = new BigDecimal(Float.toString(v1)); BigDecimal b2 = new BigDecimal(Float.toString(v2)); return b1.subtract(b2).doubleValue(); }
From source file:Main.java
public static double sub(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.subtract(b2).doubleValue(); }
From source file:Main.java
public static final double sub(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return (b1.subtract(b2)).doubleValue(); }
From source file:Main.java
public static double sub(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.subtract(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
private static double getdPoint(double num) { double d = num; int fInt = (int) d; BigDecimal b1 = new BigDecimal(Double.toString(d)); BigDecimal b2 = new BigDecimal(Integer.toString(fInt)); double dPoint = b1.subtract(b2).floatValue(); return dPoint; }
From source file:Main.java
public static double getdPoint(double num) { double d = num; int fInt = (int) d; BigDecimal b1 = new BigDecimal(Double.toString(d)); BigDecimal b2 = new BigDecimal(Integer.toString(fInt)); double dPoint = b1.subtract(b2).floatValue(); return dPoint; }
From source file:com.surfs.storage.web.utils.Stringutils.java
public static long subtractSpace(String totalSpace, String freeSpace) { //String total = convertToKB(totalSpace); //String free = convertToKB(freeSpace); BigDecimal subtract = new BigDecimal(totalSpace); long subtractNum = subtract.subtract(new BigDecimal(freeSpace)).longValue(); /*BigDecimal subtractTB = new BigDecimal(subtractNum); double divSum = subtractTB.divide(new BigDecimal("1048576"), 2, BigDecimal.ROUND_HALF_UP).doubleValue(); return String.valueOf(divSum).concat("T");*/ return subtractNum; }
From source file:Main.java
public static Double sub(Number value1, Number value2) { BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue())); return b1.subtract(b2).doubleValue(); }
From source file:org.libreplan.business.reports.dtos.Util.java
public static BigDecimal getFractionalPart(BigDecimal value) { if (value == null) { return value; }//from w w w .j a v a 2s .c o m BigDecimal fractionalPart = value.subtract(value.setScale(0, RoundingMode.FLOOR)); return (fractionalPart.compareTo(BigDecimal.ZERO) != 0) ? fractionalPart : null; }
From source file:Main.java
public static double sub2(double v1, double v2, double v3) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b3 = new BigDecimal(Double.toString(v3)); return b1.subtract(b2).subtract(b3).doubleValue(); }