package?cn.itcast_02;?
import?java.math.BigDecimal;?
/*? 생성자:? (문자열?val):? *? *?금융 관련 항목(예: 은행 화폐의 소수점, 상품 가격의 소수점): 추가? *?public?BigDecimal?subtrahend ): 빼기? *?public?BigDecimal?multiply(BigDecimal?곱하기): 곱하기? *?public?BigDecimal?divisor): 나누기? *?public?BigDecimal?divide(BigDecimal?divisor,int?scale, int?roundingMode): 몫, 소수점 이하 자릿수, 반올림 방법.
? * */?
public?class?BigDecimalDemo?{?
public?static?void?main(String[]?args)?{?
System.out.println(0.09?+?0.01);?
System.out.println(1.0?-?0.32);?
System.out.println(1.015 ?*?100);?
System.out.println(1.301?/?100);?
//?public?BigDecimal?add(BigDecimal?augend):추가 ?
BigDecimal?bd1?=?new?BigDecimal("0.09");?
BigDecimal?bd2?=?new?BigDecimal("0.01");?
System.out.println("추가:"?+?bd1.add(bd2));?
System.out.println("------------ ----------");?
//?public?BigDecimal?subtract(BigDecimal?subtrahend):subtract?
BigDecimal?bd3? =? new?BigDecimal("1.0");?
BigDecimal?bd4?=?new?BigDecimal("0.32");?
System.out.println("subtract :" ?+?bd3.subtract(bd4));?
System.out.println("--------- ") ;?
//?public?BigDecimal?multiply(BigDecimal?multiplicand):곱하기?
BigDecimal?bd5?=?new?BigDecimal("1.015");? p>
BigDecimal?bd6?=?new?BigDecimal("100");?
System.out.println("multiply:"?+?bd5.multiply(bd6)) ;?
System.out.println("---------");?
/ /? public?BigDecimal?divide(BigDecimal?divisor):divide?
BigDecimal?bd7?=?new?BigDecimal("1.301");?
BigDecimal?bd8?= ?new ?BigDecimal("100");?
System.out.println("divide:"?+?bd7.divide(bd8));?
System.out .println ("나누기:"?+?bd7.divide(bd8,3,BigDecimal.ROUND_HALF_UP));?
System.out.println("나누기:"?+?bd7.divide(bd8 ,9 ,BigDecimal.ROUND_HALF_UP));?
}?
}