Description Of MathContext: getPrecision()
The java.math.MathContext.getPrecision() returns the precision setting. This value is always non-negative.MathContext.getPrecision() method returns an int which is the value of the precision setting.
Code Example Java MathContext
import java.math.MathContext; import java.math.RoundingMode; public class BigDecimalExam { public static void main(String[] args) { MathContext mc1 = new MathContext(2); MathContext mc2 = new MathContext(2, RoundingMode.HALF_UP); int i1 = mc1.getPrecision(); int i2 = mc2.getPrecision(); // print i1, i2 values System.out.println(i1); System.out.println(i2); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น