Java BigDecimal Multiply mul(BigDecimal b1, BigDecimal b2)

Here you can find the source of mul(BigDecimal b1, BigDecimal b2)

Description

Multiply @param b1 with @param b2

License

Open Source License

Parameter

Parameter Description
b1 <code>java.math.BigDecimal</code>
b2 <code>java.math.BigDecimal</code>

Return

substract result

Declaration

public static BigDecimal mul(BigDecimal b1, BigDecimal b2) 

Method Source Code


//package com.java2s;
/*/*  www  .ja va2  s.  co  m*/
 * File: $RCSfile$
 *
 * Copyright (c) 2005 Wincor Nixdorf International GmbH,
 * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information
 * of Wincor Nixdorf ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered
 * into with Wincor Nixdorf.
 */

import java.math.BigDecimal;

public class Main {
    /**
     * Multiply @param b1 with @param b2
     *
     * @param v1 <code>double</code>
     * @param v2 <code>double</code>
     * @return substract result
     */
    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();
    }

    /**
     * Multiply @param b1 with @param b2
     *
     * @param b1 <code>java.math.BigDecimal</code>
     * @param b2 <code>java.math.BigDecimal</code>
     * @return substract result
     */
    public static BigDecimal mul(BigDecimal b1, BigDecimal b2) {
        if (b1 == null || b2 == null) {
            return null;
        }
        return b1.multiply(b2);
    }
}

Related

  1. mul(BigDecimal d1, BigDecimal d2)
  2. mul(BigDecimal v1, BigDecimal v2)
  3. mul(BigDecimal v1, BigDecimal v2)
  4. multiple(BigDecimal dividend, int divisor)