# Java.math.BigInteger.divideAndRemainder() Method

## Description

The java.math.BigInteger.divideAndRemainder(BigInteger val) returns an array of two BigIntegers containing (this / val) followed by (this % val).

## Declaration

Following is the declaration for java.math.BigInteger.divideAndRemainder() method.

```public BigInteger[] divideAndRemainder(BigInteger val)
```

## Parameters

val − Value by which this BigInteger is to be divided, and the remainder computed.

## Return Value

This method returns an array of two BigIntegers: the quotient (this / val) is the initial element, and the remainder (this % val) is the final element.

## Exception

ArithmeticException − If val is zero.

## Example

The following example shows the usage of math.BigInteger.divideAndRemainder() method.

```package com.tutorialspoint;

import java.math.*;

public class BigIntegerDemo {

public static void main(String[] args) {

// create 2 BigInteger objects
BigInteger bi1, bi2;

bi1 = new BigInteger("-100");
bi2 = new BigInteger("3");

// BigInteger array bi stores result of bi1/bi2
BigInteger bi[] = bi1.divideAndRemainder(bi2);

// print quotient and remainder
System.out.println("Division result");
System.out.println("Quotient is " + bi );
System.out.println("Remainder is " + bi );
}
}
```

Let us compile and run the above program, this will produce the following result −

```Division result
Quotient is -33
Remainder is -1
```
java_math_biginteger.htm