Example below demonstrates, working of divideAndRemainder(BigDecimal divisor) method. Method divides the bigdecimal class object value on which it is invoked, by the bigdecimal class object value passed inside the parentheses of the method.
Java BigDecimal divideAndRemainder example
Example below demonstrates, working of divideAndRemainder(BigDecimal divisor) method. Method divides the bigdecimal class object value on which it is invoked, by the bigdecimal class object value passed inside the parentheses of the method. Shortly it can said as method divides this.object value by the value of object passed. Method return type is an bigdecimal array of length two(2). This array contains the method generated results. At array index zero(array[0]) method generated first result, 'quotient' is located & at array index one(array[1]) method generated second result, 'remainder' is located.The first result 'quotient' will always possess integer format. This means method will only generate the integer part, i.e. the portion of 'quotient' before decimal.
Method will generate the remainder also as the second(array[1]) element of bigdecimal
array[].
Method throws Arithmetic Exception when the divisor value is equal to zero.
Syntax for using the method:
public BigDecimal[] divideAndRemainder(BigDecimal divisor)
bigdecimal_objectName = dividendName.divideAndRemainder(divisor)
Java_divideAndRemainder_BigDecimal_divisor.java
import java.math.BigDecimal;
|