Java BigDecimal .divideAndRemainder (BigDecimal divisor)

Syntax

BigDecimal.divideAndRemainder(BigDecimal divisor) has the following syntax.

public BigDecimal [] divideAndRemainder(BigDecimal divisor)

Example

In the following code shows how to use BigDecimal.divideAndRemainder(BigDecimal divisor) method.


/*w  w  w.ja v  a  2  s  .  c  o m*/
import java.math.BigDecimal;

public class Main {

  public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("123.145");
    BigDecimal bg2 = new BigDecimal("110.01");

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

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

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger