Java BigDecimal .remainder (BigDecimal divisor)

Syntax

BigDecimal.remainder(BigDecimal divisor) has the following syntax.

public BigDecimal remainder(BigDecimal divisor)

Example

In the following code shows how to use BigDecimal.remainder(BigDecimal divisor) method.


//from www  .  j av a 2s  .c o m
import java.math.BigDecimal;

public class Main {

  public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("513.54");
    BigDecimal bg2 = new BigDecimal("5");

    // bg2 divided by bg1 gives bg3 as remainder
    BigDecimal bg3 = bg1.remainder(bg2);

    String str = "The remainder is " + bg3;

    // print the value of bg3
    System.out.println(str);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.math »




BigDecimal
BigInteger