- Java.math package classes
- Java.math - Home
- Java.math - BigDecimal
- Java.math - BigInteger
- Java.math - MathContext
- Java.math package extras
- Java.math - Enumerations
- Java.math - Discussion
Java.math.BigDecimal.multiply() Method
Description
The java.math.BigDecimal.multiply(BigDecimal multiplicand) returns a BigDecimal whose value is (this × multiplicand), and whose scale is (this.scale() + multiplicand.scale()).
Declaration
Following is the declaration for java.math.BigDecimal.multiply() method.
public BigDecimal multiply(BigDecimal multiplicand)
Parameters
multiplicand − Value to be multiplied by this BigDecimal.
Return Value
This method returns a BigDecimal whose value this * multiplicand.
Exception
NA
Example
The following example shows the usage of math.BigDecimal.multiply() method.
package com.tutorialspoint; import java.math.*; public class BigDecimalDemo { public static void main(String[] args) { // create 3 BigDecimal objects BigDecimal bg1, bg2, bg3; bg1 = new BigDecimal("2.310"); bg2 = new BigDecimal("4.620"); // multiply bg1 with bg2 and assign result to bg3 bg3 = bg1.multiply(bg2); String str = "Multiplication Result is " +bg3; // print bg3 value System.out.println( str ); } }
Let us compile and run the above program, this will produce the following result −
Multiplication Result is 10.672200
java_math_bigdecimal.htm
Advertisements