วันอังคารที่ 23 กันยายน พ.ศ. 2557

java.math.BigDecimal.divideAndRemainder(BigDecimal divisor)

Description Of BigDecimal: divideAndRemainder(BigDecimal divisor)

The java.math.BigDecimal.divideAndRemainder(BigDecimal divisor) returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands.

Note that if both the integer quotient and remainder are needed, this method is faster than using the divideToIntegralValue and remainder methods separately because the division need only be carried out once.

BigDecimal.divideAndRemainder(BigDecimal divisor) method returns a two element BigDecimal array: the quotient (the result of divideToIntegralValue ) is the initial element and the remainder is the final element.

Code Example Java BigDecimal

import java.math.BigDecimal;

public class BigDecimalExam {
 public static void main(String[] args) {
  BigDecimal bg1 = new BigDecimal("10");
  BigDecimal bg2 = new BigDecimal("3");

  BigDecimal bg[] = bg1.divideAndRemainder(bg2);

     System.out.println("Quotient is " + bg[0]);
     System.out.println("Remainder is " + bg[1]);
 }
}


yengo หรือ buzzcity

ไม่มีความคิดเห็น :

แสดงความคิดเห็น