Code example for BigDecimal

Methods: divide

0
  public BigDecimal getPay(BigDecimal salaryBase, BigDecimal rate) {
    // TODO Auto-generated method stub 
    BigDecimal pay = new BigDecimal(0.00);
    double p =0;
    p = salaryBase.doubleValue() * rate.doubleValue();
    pay = new BigDecimal(p);
    pay = pay.divide(new BigDecimal(1),1,BigDecimal.ROUND_HALF_UP);
    return pay.divide(new BigDecimal(1),2,BigDecimal.ROUND_HALF_UP);
  } 
   
  /**¸ù¾Ý½É¶î°´ÏàÓ¦µÄ½É´æ¾«¶È·µ»Ø½É¶î 
   * pay ½É¶î 
   */ 
  public BigDecimal getPay(BigDecimal pay) {
    // TODO Auto-generated method stub 
    pay = pay.divide(new BigDecimal(1),1,BigDecimal.ROUND_HALF_UP);
    
    return pay.divide(new BigDecimal(1),2,BigDecimal.ROUND_HALF_UP);
  } 
   
}