Example below illustrates the bigdecimal class divide(BigDecimal divisor) method working.
Java BigInteger long
Example below illustrates the bigdecimal class divide(BigDecimal divisor) method working. In the example method divides the bigdecimal object value in which it is invoked by the bigdecimal object value passed inside its parentheses. The scale of the quotient is the scale of the value of object in which the method is invoked minus the scale of the value of object specified. In short scale of quotient is (this.object value scale) - (object.value scale). Moreover the result generated has to be stored by some bigdecimal object as this method returns bigdecimal object type values only.Method throws an Arithmetic Exception when a non-terminating quotient is generated. This means the quotient does not possess any termination point in to its fractional part. Method throws NumberFormatException if it finds a value other than a integer or double value.
Syntax for using the method:
System.out.println(bigdecimal_objectName.divide(BigDecimal divisor));
or
BigDecimal x = this.object.divide(divisor);
Java_BigDecimal_divide_BigDecimal_Divisor.java
import java.math.BigDecimal;
|