import java.math.BigDecimal;import java.util.Scanner;/** * Created by Administrator on 2016/9/20. */public class BigDecimalGetNumbers { public static void main(String args[]) { Scanner in = new Scanner(System.in); double dInput = in.nextDouble(); long longPart = (long) dInput; BigDecimal bigDecimal = new BigDecimal(Double.toString(dInput)); BigDecimal bigDecimalLongPart = new BigDecimal(Double.toString(longPart)); double dPoint = bigDecimal.subtract(bigDecimalLongPart).doubleValue(); System.out.println("整数部分为:" + longPart + "\n" + "小数部分为: " + dPoint); }}
测试数据:1.234567E4
1.234567E4整数部分为:12345小数部分为: 0.67Process finished with exit code 0