java.math.BigDecimal.multiply(BigDecimal multiplicand) 返回一個BigDecimal,其值為 (this × multiplicand), 其標度為其標度為 (this.scale() + multiplicand.scale()).
以下是java.math.BigDecimal.multiply()方法宣告
public BigDecimal multiply(BigDecimal multiplicand)
multiplicand - 通過此BigDecimal相乘的值
此方法返回一個BigDecimal,其的值為this * multiplicand
NA
下面的例子顯示math.BigDecimal.multiply()方法的用法
package com.yiibai; 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 ); } }
讓我們編譯和執行上面的程式,這將產生以下結果:
Multiplication Result is 10.672200