java
java5.0 ] 소수점 원하는 자릿수로 표현하기
엘라라
2009. 8. 20. 13:57
= Format형식을 이용해서 문자열로 보여주는 간단한 방법 =
int totResCnt = 44
int totCount = 8
String resPercent = "";
String pattern = "0.##";
DecimalFormat df = new DecimalFormat(pattern);
resPercent = df.format(((float)totResCnt/(float)totCount)*100);
int totResCnt = 44
int totCount = 8
String resPercent = "";
String pattern = "0.##";
DecimalFormat df = new DecimalFormat(pattern);
resPercent = df.format(((float)totResCnt/(float)totCount)*100);