본문 바로가기
모바일개발(Mobile Dev)/안드로이드개발(Android)

using parsing round math

by 테크한스 2017. 7. 16.
반응형

written by http://2ssoosike.tistory.com/149



##. 소수점 7자리에서 반올림으로 표현하고 소수점 이상은 3자리마다 콤마표시

String price ="12323445.9090900909";
String result = String.format("%,.7f", Double.parseDouble(price));
System.out.println("output: "+result);

결과

 - output: 12,323,445.909

##. java round func 이용한 반올림? (현재 숫자와 가장 근사치인 정수)

String result1 = String.format("%,d", Math.round(Double.parseDouble(price)));
System.out.println("output: "+result1);

결과

- output: 12,323,446

반응형