Description Of BigDecimal: multiply(BigDecimal multiplicand, MathContext mc)
The java.math.BigDecimal.multiply(BigDecimal multiplicand, MathContext mc) returns a BigDecimal whose value is (this ? multiplicand) , with rounding according to the context settings.BigDecimal.multiply(BigDecimal multiplicand, MathContext mc) method returns this * multiplicand , rounded as necessary.
Code Example Java BigDecimal
import java.math.BigDecimal; import java.math.MathContext; public class BigDecimalExam { public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("-75.3"); BigDecimal bg2 = new BigDecimal("25.2"); MathContext mc = new MathContext(4); // 4 precision BigDecimal bg3 = bg1.multiply(bg2, mc); // print bg3 values System.out.println(bg3); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น