Java BigInteger divideAndRemainder() method

The divideAndRemainder() methodof java BigInteger class returns an array of two BigIntegerswith being the first one be the quotient while second index corresponds to the remainder.

Syntax:

Parameter:

val-value by which this BigInteger is to be divided, and the remainder computed.

Returns:

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

Throws:

ArithmeticException- if val is zero.

Example 1

Test it Now

Output:

Result of  divideAndRemainderoperaion :
Quotient is -37
Remainder is 0

Example 2

Test it Now

Output:

java.lang.ArithmeticException: BigInteger divide by zero

Next TopicJava BigInteger




Latest Courses