Java Math BigDecimal.remainder() 方法


Java Math BigDecimal.remainder() 方法

package com.codingdict;



import java.math.*;



public class BigDecimalDemo {



   public static void main(String[] args) {



      // create 3 BigDecimal Objects

      BigDecimal bg1, bg2, bg3;



      bg1 = new BigDecimal("513.54");

      bg2 = new BigDecimal("5");



      // bg2 divided by bg1 gives bg3 as remainder

      bg3 = bg1.remainder(bg2);



      String str = "The remainder is " + bg3;



      // print the value of bg3

      System.out.println( str );

   }

}