Java BigInteger divide() method

The divide() method of Java BigInteger class is used to divide two BigInteger values.This method returns a BigInteger whose value is (this / val).

Syntax:

Returns:

This method returns a BigInteger whose value is (this / val)

Throws:

ArithmeticException- if val is zero.

Note: Since the result would be BigInteger and would not be able to hold fractions then the remainder would be discarded.

Example 1

Test it Now

Output:

Result of divideoperation is-22

Example 2

Test it Now

Output:

Result of divideoperation is 22

Example 3

Test it Now

Output:

java.lang.ArithmeticException: BigInteger divide by zero

Next TopicJava BigInteger




Latest Courses