Description Of BigDecimal: divideToIntegralValue(BigDecimal divisor, MathContext mc)
The java.math.BigDecimal.divideToIntegralValue(BigDecimal divisor, MathContext mc) returns a BigDecimal whose value is the integer part of (this / divisor) . Since the integer part of the exact quotient does not depend on the rounding mode, the rounding mode does not affect the values returned by this method. The preferred scale of the result is (this.scale() - divisor.scale()) . An ArithmeticException is thrown if the integer part of the exact quotient needs more than mc.precision digits.BigDecimal.xor(BigInteger val) method returns The integer part of this / divisor .
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("1000.12"); BigDecimal bg2 = new BigDecimal("332.32"); MathContext mc = new MathContext(2); BigDecimal bg3 = bg1.divideToIntegralValue(bg2, mc); System.out.println(bg3); } }
ไม่มีความคิดเห็น :
แสดงความคิดเห็น