Description Of MathContext: getRoundingMode()
The java.math.MathContext.getRoundingMode() returns the roundingMode setting.This will be one of RoundingMode.CEILING, RoundingMode.DOWN, RoundingMode.FLOOR, RoundingMode.HALF_DOWN, RoundingMode.HALF_EVEN, RoundingMode.HALF_UP, RoundingMode.UNNECESSARY, or RoundingMode.UP.
MathContext.getRoundingMode() method returns a RoundingMode object which is the value of the roundingMode 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, RoundingMode.DOWN); MathContext mc2 = new MathContext(2, RoundingMode.HALF_UP); RoundingMode i1 = mc1.getRoundingMode(); RoundingMode i2 = mc2.getRoundingMode(); // print i1, i2 values System.out.println(i1); System.out.println(i2); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น