Example usage for java.math BigDecimal divideAndRemainder

List of usage examples for java.math BigDecimal divideAndRemainder

Introduction

In this page you can find the example usage for java.math BigDecimal divideAndRemainder.

Prototype

public BigDecimal[] divideAndRemainder(BigDecimal divisor, MathContext mc) 

Source Link

Document

Returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands calculated with rounding according to the context settings.

Usage

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("143.145");
    BigDecimal bg2 = new BigDecimal("10.01");

    MathContext mc = new MathContext(2);

    BigDecimal bg[] = bg1.divideAndRemainder(bg2, mc);

    System.out.println("Quotient is " + bg[0]);
    System.out.println("Remainder is " + bg[1]);
}