請幫我設置BigDecimal的輸出。例如: 我需要輸出長度小於8位數字的數字,如下所示:「12345678」,如果多則輸入:「1,2345Å+ 9」。正確格式的BigDecimal輸出
toPlainString();
toEngineeringString();
toString();
是否按預期工作
方法並不:下面
public class TestBigDecimalOutput {
public static void main(String[] args) {
BigDecimal d = new BigDecimal("57657657657453646587980887663654676580.24545346565476767645");
String outPlainString = d.toPlainString();
String outEngineeringString = d.toEngineeringString();
String outString = d.toString();
System.out.println(outPlainString);
System.out.println(outEngineeringString);
System.out.println(outString);
}
}
代碼使下一個輸出:
57657657657453646587980887663654676580.24545346565476767645 57657657657453646587980887663654676580.24545346565476767645 57657657657453646587980887663654676580.24545346565476767645
給我一個提示我做錯了什麼?