프로그램 언어/Java
BigDecimal 숫자 형변환
husks
2015. 3. 13. 11:49
반응형
BigDecimal을 숫자로 형변환하는 예제입니다.
아래 소스를 참고하세요.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import java.math.BigDecimal; public class CastingTest { public static void main(String[] args) { BigDecimal bigDecimal = new BigDecimal("5"); double doubleValue = bigDecimal.doubleValue(); float floatValue = bigDecimal.floatValue(); int intValue = bigDecimal.intValue(); short shortValue = bigDecimal.shortValue(); long longValue = bigDecimal.longValue(); System.out.println("doubleValue: "+doubleValue); System.out.println("floatValue: "+floatValue); System.out.println("intValue: "+intValue); System.out.println("shortValue: "+shortValue); System.out.println("longValue: "+longValue); } } |
반응형