Java Math divideAndRemainder() 方法


Java Math divideAndRemainder() 方法

package com.codingdict;

import java.math.*;

public class BigDecimalDemo {

   public static void main(String[] args) {

      // create 2 BigDecimal objects
      BigDecimal bg1, bg2;

      bg1 = new BigDecimal("143.145");
      bg2 = new BigDecimal("10.01");

      // BigDecimal array bg stores result of bg1/bg2
      BigDecimal bg[] = bg1.divideAndRemainder(bg2);

      // print quotient and remainder
      System.out.println("Division result");
      System.out.println("Quotient is " + bg[0] );
      System.out.println("Remainder is " + bg[1] );
   }
}