Description Of BigDecimal: round(MathContext mc)
The java.math.BigDecimal.round(MathContext mc) returns a BigDecimal rounded according to the MathContext settings. If the precision setting is 0 then no rounding takes place.The effect of this method is identical to that of the plus(MathContext) method.
BigDecimal.round(MathContext mc) method returns a BigDecimal rounded according to the MathContext settings.
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("123.234");
MathContext mc = new MathContext(2);
BigDecimal bg3 = bg1.round(mc);
System.out.println(bg3);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น