Description Of BigDecimal: add(BigDecimal augend)
The java.math.BigDecimal.add(BigDecimal augend) returns a BigDecimal whose value is (this + augend) , and whose scale is max(this.scale(), augend.scale())BigDecimal.add(BigDecimal augend) method returns this + augend
Code Example Java BigDecimal
import java.math.BigDecimal;
public class BigDecimalExam {
public static void main(String[] args) {
BigDecimal bg1 = new BigDecimal("12.345");
BigDecimal bg2 = new BigDecimal("20.123");
// print bg1 and bg2 value
System.out.println("Object Value is " + bg1);
System.out.println("Augend value is " + bg2);
// perform add operation on bg1 with augend bg2
BigDecimal bg3 = bg1.add(bg2);
// print bg3 value
System.out.println("Result is " + bg3);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น