Example usage for java.math BigDecimal multiply

List of usage examples for java.math BigDecimal multiply

Introduction

In this page you can find the example usage for java.math BigDecimal multiply.

Prototype

public BigDecimal multiply(BigDecimal multiplicand) 

Source Link

Document

Returns a BigDecimal whose value is (this × multiplicand), and whose scale is (this.scale() + multiplicand.scale()) .

Usage

From source file:Main.java

public static double mul(double d1, double d2) {
    BigDecimal bd1 = new BigDecimal(Double.toString(d1));
    BigDecimal bd2 = new BigDecimal(Double.toString(d2));
    return bd1.multiply(bd2).doubleValue();
}

From source file:Main.java

public static Double mul(Double v1, Double v2) {
    BigDecimal b1 = new BigDecimal(v1.toString());
    BigDecimal b2 = new BigDecimal(v2.toString());
    return Double.valueOf(b1.multiply(b2).doubleValue());
}

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));
    return b1.multiply(b2).doubleValue();
}

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 .  c  o  m*/
}

From source file:Main.java

public static double mul(double value1, double value2) {
    BigDecimal b1 = new BigDecimal(Double.valueOf(value1));
    BigDecimal b2 = new BigDecimal(Double.valueOf(value2));
    return b1.multiply(b2).doubleValue();
}

From source file:Main.java

public static float mulFloat(Float v1, Float v2) {

    BigDecimal b1 = new BigDecimal(Float.toString(v1));

    BigDecimal b2 = new BigDecimal(Float.toString(v2));

    return b1.multiply(b2).floatValue();

}

From source file:Main.java

public static String formatPercentWithFixedFractionDigit(BigDecimal number, int fractionDigit) {
    String result = "0";

    if (number != null) {
        number = number.multiply(new BigDecimal("100"));
        DecimalFormat formatter = new DecimalFormat();
        formatter.setMaximumFractionDigits(fractionDigit);
        formatter.setMinimumFractionDigits(fractionDigit);

        result = formatter.format(number);
    }//from w w  w.  j a  v a 2s . c  o  m
    return result;
}

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));
    return b1.multiply(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}

From source file:Main.java

public static double mulDouble(double v1, double v2) {

    BigDecimal b1 = new BigDecimal(Double.toString(v1));

    BigDecimal b2 = new BigDecimal(Double.toString(v2));

    return b1.multiply(b2).doubleValue();

}

From source file:Main.java

public static Double mul(Number value1, Number value2) {
    BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue()));
    BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue()));
    return b1.multiply(b2).doubleValue();
}