Java.math.BigDecimal Class Java.math.BigDecimal.divideAndRemainder() Method - Java.math Package

What is Java math BigDecimal divideAndRemainder() Method?

Description

The java.math.BigDecimal.divideAndRemainder(BigDecimal divisor) returns a -detail BigDecimal array containing the result of divideToIntegralValue observed by using the result of remainder on the two operands calculated with rounding in step with the context settings.

If each the integer quotient and remainder are needed, this technique is faster than using the divideToIntegralValue and remainder techniques one by one due to the fact the department want only be finished once.

Declaration

Following is the declaration for java.math.BigDecimal.divideAndRemainder() technique.

Parameters

Divisor − Value by which this BigDecimal is to be divided, and the remainder computed.

Return Value

This technique returns a two detail BigDecimal array: the quotient (the result of divideToIntegralValue) is the initial detail and the remainder is the final detail.

Exception

ArithmeticException − If divisor == 0.

Example

The following instance suggests using math.BigDecimal.divideAndRemainder() technique.

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

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java.math Package Topics